Fix #31764: Show appropriate error message when fonts pubspec.yaml isn't iterable

Show appropriate error message when fonts isn't iterable
This commit is contained in:
Emmanuel Garcia
2019-05-01 09:49:39 -07:00
committed by GitHub
parent a8504405a8
commit 3e65bb060f
2 changed files with 26 additions and 3 deletions

View File

@@ -398,11 +398,11 @@ void _validateFonts(YamlList fonts, List<String> errors) {
if (fontMap['family'] != null && fontMap['family'] is! String) {
errors.add('Font family must either be null or a String.');
}
if (fontMap['fonts'] != null && fontMap['fonts'] is! YamlList) {
errors.add('Expected "fonts" to either be null or a list.');
}
if (fontMap['fonts'] == null) {
continue;
} else if (fontMap['fonts'] is! YamlList) {
errors.add('Expected "fonts" to either be null or a list.');
continue;
}
for (final YamlMap fontListItem in fontMap['fonts']) {
for (final MapEntry<dynamic, dynamic> kvp in fontListItem.entries) {