Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
af93b6af
Unverified
Commit
af93b6af
authored
Oct 11, 2019
by
Zachary Anderson
Committed by
GitHub
Oct 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Improve yaml font map validation (#42538)
parent
1ada412d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
flutter_manifest.dart
packages/flutter_tools/lib/src/flutter_manifest.dart
+7
-2
flutter_manifest_test.dart
...utter_tools/test/general.shard/flutter_manifest_test.dart
+19
-0
No files found.
packages/flutter_tools/lib/src/flutter_manifest.dart
View file @
af93b6af
...
...
@@ -439,8 +439,13 @@ void _validateFonts(YamlList fonts, List<String> errors) {
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
)
{
for
(
final
dynamic
fontListItem
in
fontMap
[
'fonts'
])
{
if
(
fontListItem
is
!
YamlMap
)
{
errors
.
add
(
'Expected "fonts" to be a list of maps.'
);
continue
;
}
final
YamlMap
fontMapList
=
fontListItem
;
for
(
final
MapEntry
<
dynamic
,
dynamic
>
kvp
in
fontMapList
.
entries
)
{
if
(
kvp
.
key
is
!
String
)
{
errors
.
add
(
'Expected "
${kvp.key}
" under "fonts" to be a string.'
);
}
...
...
packages/flutter_tools/test/general.shard/flutter_manifest_test.dart
View file @
af93b6af
...
...
@@ -534,6 +534,25 @@ flutter:
expect
(
logger
.
errorText
,
contains
(
'Expected "fonts" to either be null or a list.'
));
});
testUsingContext
(
'Returns proper error when font detail is not a list of maps'
,
()
async
{
final
BufferLogger
logger
=
context
.
get
<
Logger
>();
const
String
manifest
=
'''
name: test
dependencies:
flutter:
sdk: flutter
flutter:
fonts:
- family: foo
fonts:
- asset
'''
;
final
FlutterManifest
flutterManifest
=
FlutterManifest
.
createFromString
(
manifest
);
expect
(
flutterManifest
,
null
);
expect
(
logger
.
errorText
,
contains
(
'Expected "fonts" to be a list of maps.'
));
});
testUsingContext
(
'Returns proper error when font is a map instead of a list'
,
()
async
{
final
BufferLogger
logger
=
context
.
get
<
Logger
>();
const
String
manifest
=
'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment