enable lints prefer_const_declarations and prefer_const_literals_to_create_immutables (#14848)
diff --git a/analysis_options.yaml b/analysis_options.yaml index b202799..78a2e88 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml
@@ -109,8 +109,8 @@ - prefer_conditional_assignment - prefer_const_constructors - prefer_const_constructors_in_immutables - # - prefer_const_declarations # not yet tested - # - prefer_const_literals_to_create_immutables # not yet tested + - prefer_const_declarations + - prefer_const_literals_to_create_immutables # - prefer_constructors_over_static_methods # not yet tested - prefer_contains # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
diff --git a/analysis_options_repo.yaml b/analysis_options_repo.yaml index fed4ed5..65ebfb7 100644 --- a/analysis_options_repo.yaml +++ b/analysis_options_repo.yaml
@@ -102,8 +102,8 @@ - prefer_conditional_assignment - prefer_const_constructors - prefer_const_constructors_in_immutables - # - prefer_const_declarations # not yet tested - # - prefer_const_literals_to_create_immutables # not yet tested + - prefer_const_declarations + - prefer_const_literals_to_create_immutables # - prefer_constructors_over_static_methods # not yet tested - prefer_contains # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index 368ba56..53c8379 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart
@@ -116,7 +116,7 @@ child: new CupertinoAlertDialog( title: const Text('The Title'), content: new Text('Very long content ' * 20), - actions: <Widget>[ + actions: const <Widget>[ const CupertinoDialogAction( child: const Text('Cancel'), ),
diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 64783b5..a0c626e 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart
@@ -10,7 +10,7 @@ Widget buildSliverAppBarApp({ bool floating, bool pinned, double expandedHeight, bool snap: false }) { return new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ],
diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index c10e4d2..32de24a 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart
@@ -241,7 +241,7 @@ await tester.pumpWidget( new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ], @@ -256,7 +256,7 @@ await tester.pumpWidget( new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ], @@ -428,7 +428,7 @@ await tester.pumpWidget( new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ], @@ -468,7 +468,7 @@ await tester.pumpWidget( new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ],
diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 0c1f0f6..a8d08f6 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart
@@ -236,7 +236,7 @@ await tester.pumpWidget(new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ],
diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index 966da83..09132c1 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart
@@ -65,7 +65,7 @@ Widget build(BuildContext context) { return new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ],
diff --git a/packages/flutter/test/material/modal_bottom_sheet_test.dart b/packages/flutter/test/material/modal_bottom_sheet_test.dart index 0881a40..fb393a6 100644 --- a/packages/flutter/test/material/modal_bottom_sheet_test.dart +++ b/packages/flutter/test/material/modal_bottom_sheet_test.dart
@@ -160,7 +160,7 @@ await tester.pumpWidget(new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ],
diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index daedc4d..905ff04 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart
@@ -442,7 +442,7 @@ Widget build(BuildContext context) { return new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ],
diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 13df2a7..72ea8f8 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart
@@ -363,7 +363,7 @@ child: const Text('body'), ), ), - persistentFooterButtons: <Widget>[const Placeholder()], + persistentFooterButtons: const <Widget>[const Placeholder()], ), ), ), @@ -1056,7 +1056,7 @@ if (geometryListenable != null) geometryListenable.removeListener(onGeometryChanged); - + geometryListenable = newListenable; geometryListenable.addListener(onGeometryChanged); cache = new GeometryCachePainter(geometryListenable);
diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index b3fbe0c..da3dd43 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart
@@ -360,7 +360,7 @@ ), child: new Scaffold( bottomNavigationBar: new BottomNavigationBar( - items: <BottomNavigationBarItem>[ + items: const <BottomNavigationBarItem>[ const BottomNavigationBarItem(icon: const Icon(Icons.favorite), title: const Text('Animutation')), const BottomNavigationBarItem(icon: const Icon(Icons.block), title: const Text('Zombo.com')), ],
diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 89de8f2..316122c 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart
@@ -17,7 +17,7 @@ Widget boilerplate({ Widget child, TextDirection textDirection: TextDirection.ltr }) { return new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], @@ -1661,7 +1661,7 @@ alignment: Alignment.topLeft, child: new TabBar( controller: controller, - tabs: <Tab>[ + tabs: const <Tab>[ const Tab(text: 'LEFT'), const Tab(text: 'RIGHT'), ],
diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index bd7cd2d..6ec59c1 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart
@@ -229,7 +229,7 @@ await tester.pumpWidget( new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ],
diff --git a/packages/flutter/test/widgets/nested_scroll_view_test.dart b/packages/flutter/test/widgets/nested_scroll_view_test.dart index 4b07098..b879116 100644 --- a/packages/flutter/test/widgets/nested_scroll_view_test.dart +++ b/packages/flutter/test/widgets/nested_scroll_view_test.dart
@@ -25,7 +25,7 @@ Widget buildTest({ ScrollController controller, String title:'TTTTTTTT' }) { return new Localizations( locale: const Locale('en', 'US'), - delegates: <LocalizationsDelegate<dynamic>>[ + delegates: const <LocalizationsDelegate<dynamic>>[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ],
diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index 418675e..04d3259 100644 --- a/packages/flutter/test/widgets/parent_data_test.dart +++ b/packages/flutter/test/widgets/parent_data_test.dart
@@ -253,7 +253,7 @@ await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, - children: <Widget>[ + children: const <Widget>[ const Positioned( top: 5.0, bottom: 8.0, @@ -275,7 +275,7 @@ await tester.pumpWidget( new Container( child: new Row( - children: <Widget>[ + children: const <Widget>[ const Positioned( top: 6.0, left: 7.0,
diff --git a/packages/flutter/test/widgets/semantics_test.dart b/packages/flutter/test/widgets/semantics_test.dart index d6ad7cb..e43748d 100644 --- a/packages/flutter/test/widgets/semantics_test.dart +++ b/packages/flutter/test/widgets/semantics_test.dart
@@ -913,7 +913,7 @@ const Text('Label 1'), const Text('Label 2'), new Row( - children: <Widget>[ + children: const <Widget>[ const Text('Label 3'), const Text('Label 4'), const Text('Label 5'), @@ -976,7 +976,7 @@ new Transform.rotate( angle: pi / 2.0, child: new Row( - children: <Widget>[ + children: const <Widget>[ const Text('Label 3'), const Text('Label 4'), const Text('Label 5'),
diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart index d7d2932..7f03bf6 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart
@@ -15,7 +15,7 @@ data: const MediaQueryData(), child: new CustomScrollView( controller: controller, - slivers: <Widget>[ + slivers: const <Widget>[ const SliverAppBar(floating: true, pinned: true, expandedHeight: 200.0, title: const Text('A')), const SliverAppBar(primary: false, pinned: true, title: const Text('B')), const SliverList(
diff --git a/packages/flutter/test/widgets/slivers_block_test.dart b/packages/flutter/test/widgets/slivers_block_test.dart index 4a05643..5984c8b 100644 --- a/packages/flutter/test/widgets/slivers_block_test.dart +++ b/packages/flutter/test/widgets/slivers_block_test.dart
@@ -14,7 +14,7 @@ textDirection: TextDirection.ltr, child: new Viewport( offset: new ViewportOffset.fixed(offset), - slivers: <Widget>[ + slivers: const <Widget>[ const SliverList( delegate: const SliverChildListDelegate(const <Widget>[ const SizedBox(height: 400.0, child: const Text('a')), @@ -150,7 +150,7 @@ textDirection: TextDirection.ltr, child: new Viewport( offset: offset, - slivers: <Widget>[ + slivers: const <Widget>[ const SliverList( delegate: const SliverChildListDelegate(const <Widget>[ const SizedBox(height: 251.0, child: const Text('a')), @@ -261,7 +261,7 @@ textDirection: TextDirection.ltr, child: new Viewport( offset: new ViewportOffset.zero(), - slivers: <Widget>[ + slivers: const <Widget>[ const SliverList( delegate: const SliverChildListDelegate(const <Widget>[ const SizedBox(height: 400.0, child: const Text('a')), @@ -279,7 +279,7 @@ textDirection: TextDirection.ltr, child: new Viewport( offset: new ViewportOffset.fixed(100.0), - slivers: <Widget>[ + slivers: const <Widget>[ const SliverList( delegate: const SliverChildListDelegate(const <Widget>[ const SizedBox(height: 400.0, child: const Text('a')), @@ -297,7 +297,7 @@ textDirection: TextDirection.ltr, child: new Viewport( offset: new ViewportOffset.fixed(100.0), - slivers: <Widget>[ + slivers: const <Widget>[ const SliverList( delegate: const SliverChildListDelegate(const <Widget>[ const SizedBox(height: 4000.0, child: const Text('a')), @@ -315,7 +315,7 @@ textDirection: TextDirection.ltr, child: new Viewport( offset: new ViewportOffset.zero(), - slivers: <Widget>[ + slivers: const <Widget>[ const SliverList( delegate: const SliverChildListDelegate(const <Widget>[ const SizedBox(height: 4000.0, child: const Text('a')),
diff --git a/packages/flutter_localizations/test/date_time_test.dart b/packages/flutter_localizations/test/date_time_test.dart index 4f282b1..00138e3 100644 --- a/packages/flutter_localizations/test/date_time_test.dart +++ b/packages/flutter_localizations/test/date_time_test.dart
@@ -31,7 +31,7 @@ await tester.pumpWidget(new MaterialApp( supportedLocales: <Locale>[locale], locale: locale, - localizationsDelegates: <LocalizationsDelegate<dynamic>>[ + localizationsDelegates: const <LocalizationsDelegate<dynamic>>[ GlobalMaterialLocalizations.delegate, ], home: new Builder(builder: (BuildContext context) { @@ -85,7 +85,7 @@ await tester.pumpWidget(new MaterialApp( supportedLocales: <Locale>[locale], locale: locale, - localizationsDelegates: <LocalizationsDelegate<dynamic>>[ + localizationsDelegates: const <LocalizationsDelegate<dynamic>>[ GlobalMaterialLocalizations.delegate, ], home: new Builder(builder: (BuildContext context) {
diff --git a/packages/flutter_tools/lib/src/base/utils.dart b/packages/flutter_tools/lib/src/base/utils.dart index 5d33997..cbbc5dd 100644 --- a/packages/flutter_tools/lib/src/base/utils.dart +++ b/packages/flutter_tools/lib/src/base/utils.dart
@@ -15,7 +15,7 @@ import 'file_system.dart'; import 'platform.dart'; -final BotDetector _kBotDetector = const BotDetector(); +const BotDetector _kBotDetector = const BotDetector(); class BotDetector { const BotDetector();