mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
[flutter_tool] Additional flutter manifest yaml validation (#37422)
This commit is contained in:
parent
4ccd81199f
commit
500d7c50df
|
@ -404,7 +404,12 @@ void _validateFonts(YamlList fonts, List<String> errors) {
|
|||
const Set<int> fontWeights = <int>{
|
||||
100, 200, 300, 400, 500, 600, 700, 800, 900,
|
||||
};
|
||||
for (final YamlMap fontMap in fonts) {
|
||||
for (final dynamic fontListEntry in fonts) {
|
||||
if (fontListEntry is! YamlMap) {
|
||||
errors.add('Unexpected child "$fontListEntry" found under "fonts". Expected a map.');
|
||||
continue;
|
||||
}
|
||||
final YamlMap fontMap = fontListEntry;
|
||||
for (dynamic key in fontMap.keys.where((dynamic key) => key != 'family' && key != 'fonts')) {
|
||||
errors.add('Unexpected child "$key" found under "fonts".');
|
||||
}
|
||||
|
|
|
@ -518,6 +518,26 @@ flutter:
|
|||
expect(flutterManifest, null);
|
||||
expect(logger.errorText, contains('Expected "fonts" to either be null or a list.'));
|
||||
});
|
||||
|
||||
testUsingContext('Returns proper error when second font family is invalid', () async {
|
||||
final BufferLogger logger = context.get<Logger>();
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
fonts:
|
||||
- family: foo
|
||||
fonts:
|
||||
- asset: a/bar
|
||||
- string
|
||||
''';
|
||||
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
|
||||
expect(flutterManifest, null);
|
||||
expect(logger.errorText, contains('Expected a map.'));
|
||||
});
|
||||
});
|
||||
|
||||
group('FlutterManifest with MemoryFileSystem', () {
|
||||
|
|
Loading…
Reference in a new issue