diff --git a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy index d6e2bf9832094..614e0a9efa64c 100644 --- a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy +++ b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy @@ -1404,7 +1404,11 @@ class FlutterPlugin implements Plugin { // Update the app_id to the correct flavor if one was provided. if (variant.flavorName != null && !variant.flavorName.isEmpty()) { - shorebirdYamlData['app_id'] = shorebirdYamlData.flavors[variant.flavorName] + def shorebirdFlavor = shorebirdYamlData.flavors[variant.flavorName] + if (shorebirdFlavor == null) { + throw new GradleException("Flavor '${variant.flavorName}' not found in shorebird.yaml") + } + shorebirdYamlData['app_id'] = shorebirdFlavor } // Remove any flavors. This is a no-op if the flavors key doesn't exist. diff --git a/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart b/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart index 68a373a3e8548..7b1ba4a5622a6 100644 --- a/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart +++ b/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart @@ -85,7 +85,16 @@ base_url: https://example.com final Directory tempDir = Directory.systemTemp.createTempSync('shorebird_yaml_test.'); final File tempFile = File('${tempDir.path}/shorebird.yaml'); tempFile.writeAsStringSync(yamlContents); - updateShorebirdYaml(const BuildInfo(BuildMode.release, 'foo', treeShakeIcons: false), tempFile.path, environment: {'SHOREBIRD_PUBLIC_KEY': '4-a'}); + updateShorebirdYaml( + const BuildInfo( + BuildMode.release, + 'foo', + treeShakeIcons: false, + packageConfigPath: '', + ), + tempFile.path, + environment: {'SHOREBIRD_PUBLIC_KEY': '4-a'}, + ); final String updatedContents = tempFile.readAsStringSync(); // Order is not guaranteed, so parse as YAML to compare. final YamlDocument updated = loadYamlDocument(updatedContents);