diff --git a/packages/flutter_tools/lib/src/flutter_manifest.dart b/packages/flutter_tools/lib/src/flutter_manifest.dart index 4a6223de72..cd1f69aca4 100644 --- a/packages/flutter_tools/lib/src/flutter_manifest.dart +++ b/packages/flutter_tools/lib/src/flutter_manifest.dart @@ -161,7 +161,11 @@ class FlutterManifest { if (isPlugin) { final YamlMap plugin = _flutterDescriptor['plugin'] as YamlMap; if (plugin.containsKey('platforms')) { - return plugin['platforms']['android']['package'] as String; + final YamlMap platforms = plugin['platforms'] as YamlMap; + + if (platforms.containsKey('android')) { + return platforms['android']['package'] as String; + } } else { return plugin['androidPackage'] as String; } diff --git a/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart b/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart index 5886197b87..81f98300c3 100644 --- a/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart +++ b/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart @@ -387,7 +387,8 @@ flutter: expect(flutterManifest.isPlugin, true); expect(flutterManifest.androidPackage, 'com.example'); }); - test('allows a multi-plat plugin declaration', () async { + + test('allows a multi-plat plugin declaration with android only', () async { const String manifest = ''' name: test flutter: @@ -402,6 +403,20 @@ flutter: expect(flutterManifest.androidPackage, 'com.example'); }); + test('allows a multi-plat plugin declaration with ios only', () async { + const String manifest = ''' +name: test +flutter: + plugin: + platforms: + ios: + pluginClass: HelloPlugin +'''; + final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest); + expect(flutterManifest.isPlugin, true); + expect(flutterManifest.androidPackage, isNull); + }); + testUsingContext('handles an invalid plugin declaration', () async { const String manifest = ''' name: test