Skip to content

Commit a541934

Browse files
a14nfluttergithubbot
authored andcommitted
enable lint prefer_for_elements_to_map_fromIterable (flutter#47726)
1 parent d1349f6 commit a541934

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ linter:
143143
- prefer_final_fields
144144
- prefer_final_in_for_each
145145
- prefer_final_locals
146-
# - prefer_for_elements_to_map_fromIterable # not yet tested
146+
- prefer_for_elements_to_map_fromIterable
147147
- prefer_foreach
148148
# - prefer_function_declarations_over_variables # not yet tested
149149
- prefer_generic_function_type_aliases

examples/flutter_gallery/lib/gallery/app.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ class _GalleryAppState extends State<GalleryApp> {
5151
// For a different example of how to set up an application routing table
5252
// using named routes, consider the example in the Navigator class documentation:
5353
// https://docs.flutter.io/flutter/widgets/Navigator-class.html
54-
return Map<String, WidgetBuilder>.fromIterable(
55-
kAllGalleryDemos,
56-
key: (dynamic demo) => '${(demo as GalleryDemo).routeName}',
57-
value: (dynamic demo) => (demo as GalleryDemo).buildRoute,
58-
);
54+
return <String, WidgetBuilder>{
55+
for (final GalleryDemo demo in kAllGalleryDemos) demo.routeName: demo.buildRoute,
56+
};
5957
}
6058

6159
@override

examples/flutter_gallery/lib/gallery/demos.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,7 @@ final Map<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos =
579579
},
580580
);
581581

582-
final Map<String, String> kDemoDocumentationUrl =
583-
Map<String, String>.fromIterable(
584-
kAllGalleryDemos.where((GalleryDemo demo) => demo.documentationUrl != null),
585-
key: (dynamic demo) => (demo as GalleryDemo).routeName,
586-
value: (dynamic demo) => (demo as GalleryDemo).documentationUrl,
587-
);
582+
final Map<String, String> kDemoDocumentationUrl = <String, String>{
583+
for (final GalleryDemo demo in kAllGalleryDemos)
584+
if (demo.documentationUrl != null) demo.routeName: demo.documentationUrl,
585+
};

0 commit comments

Comments
 (0)