enable lint prefer_for_elements_to_map_fromIterable (#47726)

This commit is contained in:
Alexandre Ardhuin 2020-01-08 17:03:02 +01:00 committed by Flutter GitHub Bot
parent d1349f698b
commit a541934125
3 changed files with 8 additions and 12 deletions

View file

@ -143,7 +143,7 @@ linter:
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
# - prefer_for_elements_to_map_fromIterable # not yet tested
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
# - prefer_function_declarations_over_variables # not yet tested
- prefer_generic_function_type_aliases

View file

@ -51,11 +51,9 @@ class _GalleryAppState extends State<GalleryApp> {
// For a different example of how to set up an application routing table
// using named routes, consider the example in the Navigator class documentation:
// https://docs.flutter.io/flutter/widgets/Navigator-class.html
return Map<String, WidgetBuilder>.fromIterable(
kAllGalleryDemos,
key: (dynamic demo) => '${(demo as GalleryDemo).routeName}',
value: (dynamic demo) => (demo as GalleryDemo).buildRoute,
);
return <String, WidgetBuilder>{
for (final GalleryDemo demo in kAllGalleryDemos) demo.routeName: demo.buildRoute,
};
}
@override

View file

@ -579,9 +579,7 @@ final Map<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos =
},
);
final Map<String, String> kDemoDocumentationUrl =
Map<String, String>.fromIterable(
kAllGalleryDemos.where((GalleryDemo demo) => demo.documentationUrl != null),
key: (dynamic demo) => (demo as GalleryDemo).routeName,
value: (dynamic demo) => (demo as GalleryDemo).documentationUrl,
);
final Map<String, String> kDemoDocumentationUrl = <String, String>{
for (final GalleryDemo demo in kAllGalleryDemos)
if (demo.documentationUrl != null) demo.routeName: demo.documentationUrl,
};