[flutter_tools] fix crash if the platform section was a list (#60927)
Missed validation to go with cast. Added test case to reproduce.
This commit is contained in:
@@ -214,6 +214,10 @@ class Plugin {
|
||||
}
|
||||
|
||||
if (usesNewPluginFormat) {
|
||||
if (yaml['platforms'] != null && yaml['platforms'] is! YamlMap) {
|
||||
const String errorMessage = 'flutter.plugin.platforms should be a map with the platform name as the key';
|
||||
return <String>[errorMessage];
|
||||
}
|
||||
return _validateMultiPlatformYaml(yaml['platforms'] as YamlMap);
|
||||
} else {
|
||||
return _validateLegacyYaml(yaml);
|
||||
|
||||
@@ -943,6 +943,26 @@ flutter:
|
||||
<String, dynamic>{'pluginClass': 'SomeClass',
|
||||
'package': 'com.example'});
|
||||
});
|
||||
|
||||
testWithoutContext('FlutterManifest validates a platform section that is a list '
|
||||
'instead of a map', () {
|
||||
const String manifest = '''
|
||||
name: test
|
||||
flutter:
|
||||
plugin:
|
||||
platforms:
|
||||
- android
|
||||
''';
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FlutterManifest flutterManifest = FlutterManifest.createFromString(
|
||||
manifest,
|
||||
logger: logger,
|
||||
);
|
||||
|
||||
expect(flutterManifest, null);
|
||||
expect(logger.errorText,
|
||||
contains('flutter.plugin.platforms should be a map with the platform name as the key'));
|
||||
});
|
||||
}
|
||||
|
||||
Matcher matchesManifest({
|
||||
|
||||
Reference in New Issue
Block a user