Fix YamlMap cast error (#49253)

This commit is contained in:
Jenn Magder 2020-01-21 16:43:16 -08:00 committed by GitHub
parent 3800bb7b10
commit d8092d999a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -342,8 +342,9 @@ bool _validate(YamlMap manifest) {
} }
if (kvp.value is! YamlMap) { if (kvp.value is! YamlMap) {
errors.add('Expected "${kvp.key}" section to be an object or null, but got ${kvp.value}.'); errors.add('Expected "${kvp.key}" section to be an object or null, but got ${kvp.value}.');
} else {
_validateFlutter(kvp.value as YamlMap, errors);
} }
_validateFlutter(kvp.value as YamlMap, errors);
break; break;
default: default:
// additionalProperties are allowed. // additionalProperties are allowed.

View File

@ -641,6 +641,21 @@ flutter:
expect(assets[1].path, 'lib/gallery/abc%3Fxyz'); expect(assets[1].path, 'lib/gallery/abc%3Fxyz');
expect(assets[2].path, 'lib/gallery/aaa%20bbb'); expect(assets[2].path, 'lib/gallery/aaa%20bbb');
}); });
testUsingContext('Returns proper error when flutter is a list instead of a map', () async {
const String manifest = '''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
- uses-material-design: true
''';
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(testLogger.errorText, contains('Expected "flutter" section to be an object or null, but got [{uses-material-design: true}].'));
});
}); });
group('FlutterManifest with MemoryFileSystem', () { group('FlutterManifest with MemoryFileSystem', () {