Skip to content

Commit

Permalink
enable lint prefer_for_elements_to_map_fromIterable (flutter#47726)
Browse files Browse the repository at this point in the history
  • Loading branch information
a14n authored and fluttergithubbot committed Jan 8, 2020
1 parent d1349f6 commit a541934
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions examples/flutter_gallery/lib/gallery/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions examples/flutter_gallery/lib/gallery/demos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit a541934

Please sign in to comment.