From 2512163ebe54f1b81770a48544e79ad0de144199 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 6 Feb 2020 15:50:04 -0800 Subject: [PATCH] Allow Android to be missing from multi-platform manifest (#50304) --- .../flutter_tools/lib/src/flutter_manifest.dart | 6 +++++- .../general.shard/flutter_manifest_test.dart | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) 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