diff --git a/examples/flutter_gallery/lib/demo/contacts_demo.dart b/examples/flutter_gallery/lib/demo/contacts_demo.dart index 0e9a9b1b6e..6114763b17 100644 --- a/examples/flutter_gallery/lib/demo/contacts_demo.dart +++ b/examples/flutter_gallery/lib/demo/contacts_demo.dart @@ -128,15 +128,15 @@ class ContactsDemoState extends State { }); }, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: AppBarBehavior.normal, child: const Text('App bar scrolls away') ), - new PopupMenuItem( + const PopupMenuItem( value: AppBarBehavior.pinned, child: const Text('App bar stays put') ), - new PopupMenuItem( + const PopupMenuItem( value: AppBarBehavior.floating, child: const Text('App bar floats') ), diff --git a/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart b/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart index 7acc30ef0d..e63f3a6905 100644 --- a/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart @@ -192,11 +192,11 @@ class _BottomNavigationDemoState extends State }); }, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: BottomNavigationBarType.fixed, child: const Text('Fixed'), ), - new PopupMenuItem( + const PopupMenuItem( value: BottomNavigationBarType.shifting, child: const Text('Shifting'), ) diff --git a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart index 15dba3740f..f74110567f 100644 --- a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart @@ -317,15 +317,15 @@ class GridListDemoState extends State { new PopupMenuButton( onSelected: changeTileStyle, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: GridDemoTileStyle.imageOnly, child: const Text('Image only'), ), - new PopupMenuItem( + const PopupMenuItem( value: GridDemoTileStyle.oneLine, child: const Text('One line'), ), - new PopupMenuItem( + const PopupMenuItem( value: GridDemoTileStyle.twoLine, child: const Text('Two line'), ), diff --git a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart index 72ccbc14a8..8010f5ecab 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -137,11 +137,11 @@ class LeaveBehindDemoState extends State { new PopupMenuButton( onSelected: handleDemoAction, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: LeaveBehindDemoAction.reset, child: const Text('Reset the list') ), - new PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771 + const PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771 new CheckedPopupMenuItem( value: LeaveBehindDemoAction.horizontalSwipe, checked: _dismissDirection == DismissDirection.horizontal, diff --git a/examples/flutter_gallery/lib/demo/material/menu_demo.dart b/examples/flutter_gallery/lib/demo/material/menu_demo.dart index 9a5ffadf8e..d4942abe04 100644 --- a/examples/flutter_gallery/lib/demo/material/menu_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/menu_demo.dart @@ -67,15 +67,15 @@ class MenuDemoState extends State { new PopupMenuButton( onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: 'Toolbar menu', child: const Text('Toolbar menu') ), - new PopupMenuItem( + const PopupMenuItem( value: 'Right here', child: const Text('Right here') ), - new PopupMenuItem( + const PopupMenuItem( value: 'Hooray!', child: const Text('Hooray!') ), @@ -99,7 +99,7 @@ class MenuDemoState extends State { value: _simpleValue1, child: const Text('Context menu item one') ), - new PopupMenuItem( + const PopupMenuItem( enabled: false, child: const Text('A disabled menu item') ), @@ -140,7 +140,7 @@ class MenuDemoState extends State { title: const Text('Get link') ) ), - new PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771 + const PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771 new PopupMenuItem( value: 'Remove', child: new ListTile( diff --git a/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart b/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart index 4b55eedebc..02c9691e6f 100644 --- a/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart @@ -63,17 +63,17 @@ class _ProgressIndicatorDemoState extends State with Sing Widget _buildIndicators(BuildContext context, Widget child) { final List indicators = [ - new SizedBox( + const SizedBox( width: 200.0, - child: new LinearProgressIndicator() + child: const LinearProgressIndicator() ), - new LinearProgressIndicator(), - new LinearProgressIndicator(), + const LinearProgressIndicator(), + const LinearProgressIndicator(), new LinearProgressIndicator(value: _animation.value), new Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new CircularProgressIndicator(), + const CircularProgressIndicator(), new SizedBox( width: 20.0, height: 20.0, diff --git a/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart b/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart index 54213d62a0..0d02fab0e0 100644 --- a/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart @@ -64,15 +64,15 @@ class ScrollableTabsDemoState extends State with SingleTicke new PopupMenuButton( onSelected: changeDemoStyle, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: TabsDemoStyle.iconsAndText, child: const Text('Icons and text') ), - new PopupMenuItem( + const PopupMenuItem( value: TabsDemoStyle.iconsOnly, child: const Text('Icons only') ), - new PopupMenuItem( + const PopupMenuItem( value: TabsDemoStyle.textOnly, child: const Text('Text only') ), diff --git a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart index 009ef14f27..fb0df4fabd 100644 --- a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart @@ -174,8 +174,8 @@ class _SelectionControlsDemoState extends State { } ), // Disabled switches - new Switch(value: true, onChanged: null), - new Switch(value: false, onChanged: null) + const Switch(value: true, onChanged: null), + const Switch(value: false, onChanged: null) ], ), ); diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart index e1f877934c..d6842cb4e3 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart @@ -113,15 +113,15 @@ class ShrinePageState extends State { ), new PopupMenuButton( itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: ShrineAction.sortByPrice, child: const Text('Sort by price') ), - new PopupMenuItem( + const PopupMenuItem( value: ShrineAction.sortByProduct, child: const Text('Sort by product') ), - new PopupMenuItem( + const PopupMenuItem( value: ShrineAction.emptyCart, child: const Text('Empty shopping cart') ) diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart index a7fab8b0bf..be4fc4c60a 100644 --- a/examples/flutter_gallery/lib/gallery/demo.dart +++ b/examples/flutter_gallery/lib/gallery/demo.dart @@ -128,8 +128,8 @@ class FullScreenCodeDialogState extends State { Widget body; if (_exampleCode == null) { - body = new Center( - child: new CircularProgressIndicator() + body = const Center( + child: const CircularProgressIndicator() ); } else { body = new SingleChildScrollView( diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index f594f61801..f522240180 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -192,7 +192,7 @@ new Switch( // Create a disabled switch. // Switches are disabled when onChanged isn't // specified or null. -new Switch(value: false, onChanged: null); +const Switch(value: false, onChanged: null); // END } } diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index a8749d1e6f..dc8da524e1 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -209,15 +209,15 @@ class StockHomeState extends State { checked: _autorefresh, child: const Text('Autorefresh'), ), - new PopupMenuItem<_StockMenuItem>( + const PopupMenuItem<_StockMenuItem>( value: _StockMenuItem.refresh, child: const Text('Refresh'), ), - new PopupMenuItem<_StockMenuItem>( + const PopupMenuItem<_StockMenuItem>( value: _StockMenuItem.speedUp, child: const Text('Increase animation speed'), ), - new PopupMenuItem<_StockMenuItem>( + const PopupMenuItem<_StockMenuItem>( value: _StockMenuItem.speedDown, child: const Text('Decrease animation speed'), ), diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index 760a8c7c4d..9ae8cae693 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -434,10 +434,10 @@ class _LicensePageState extends State { ]; contents.addAll(_licenses); if (!_loaded) { - contents.add(new Padding( + contents.add(const Padding( padding: const EdgeInsets.symmetric(vertical: 24.0), - child: new Center( - child: new CircularProgressIndicator() + child: const Center( + child: const CircularProgressIndicator() ) )); } diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index fd88271afa..f1b9354fd8 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -484,7 +484,7 @@ class _AppBarState extends State { } class _FloatingAppBar extends StatefulWidget { - _FloatingAppBar({ Key key, this.child }) : super(key: key); + const _FloatingAppBar({ Key key, this.child }) : super(key: key); final Widget child; diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index b517457c18..a4063c1e2f 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -243,13 +243,13 @@ class PaginatedDataTableState extends State { final List cells = widget.columns.map((DataColumn column) { if (!column.numeric) { haveProgressIndicator = true; - return new DataCell(new CircularProgressIndicator()); + return const DataCell(const CircularProgressIndicator()); } return DataCell.empty; }).toList(); if (!haveProgressIndicator) { haveProgressIndicator = true; - cells[0] = new DataCell(new CircularProgressIndicator()); + cells[0] = const DataCell(const CircularProgressIndicator()); } return new DataRow.byIndex( index: index, diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 4ad5fff3e5..110da6d3b1 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -76,7 +76,7 @@ class PopupMenuDivider extends PopupMenuEntry { /// Creates a horizontal divider for a popup menu. /// /// By default, the divider has a height of 16.0 logical pixels. - PopupMenuDivider({ Key key, this.height: 16.0 }) : super(key: key); + const PopupMenuDivider({ Key key, this.height: 16.0 }) : super(key: key); @override final double height; @@ -111,7 +111,7 @@ class PopupMenuItem extends PopupMenuEntry { /// Creates an item for a popup menu. /// /// By default, the item is enabled. - PopupMenuItem({ + const PopupMenuItem({ Key key, this.value, this.enabled: true, @@ -195,7 +195,7 @@ class CheckedPopupMenuItem extends PopupMenuItem { /// Creates a popup menu item with a checkmark. /// /// By default, the menu item is enabled but unchecked. - CheckedPopupMenuItem({ + const CheckedPopupMenuItem({ Key key, T value, this.checked: false, @@ -252,7 +252,7 @@ class _CheckedPopupMenuItemState extends _PopupMenuItemState extends StatelessWidget { - _PopupMenu({ + const _PopupMenu({ Key key, this.route }) : super(key: key); diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index c14040cfef..959644fe62 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -30,7 +30,7 @@ abstract class ProgressIndicator extends StatefulWidget { /// The [value] argument can be either null (corresponding to an indeterminate /// progress indcator) or non-null (corresponding to a determinate progress /// indicator). See [value] for details. - ProgressIndicator({ + const ProgressIndicator({ Key key, this.value, this.backgroundColor, @@ -137,7 +137,7 @@ class LinearProgressIndicator extends ProgressIndicator { /// The [value] argument can be either null (corresponding to an indeterminate /// progress indcator) or non-null (corresponding to a determinate progress /// indicator). See [value] for details. - LinearProgressIndicator({ + const LinearProgressIndicator({ Key key, double value }) : super(key: key, value: value); @@ -278,7 +278,7 @@ class CircularProgressIndicator extends ProgressIndicator { /// The [value] argument can be either null (corresponding to an indeterminate /// progress indcator) or non-null (corresponding to a determinate progress /// indicator). See [value] for details. - CircularProgressIndicator({ + const CircularProgressIndicator({ Key key, double value, Color backgroundColor, @@ -438,7 +438,7 @@ class RefreshProgressIndicator extends CircularProgressIndicator { /// /// Rather than creating a refresh progress indicator directly, consider using /// a [RefreshIndicator] together with a [Scrollable] widget. - RefreshProgressIndicator({ + const RefreshProgressIndicator({ Key key, double value, Color backgroundColor, diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index 54937f64ed..da61fc049d 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -42,7 +42,7 @@ class Switch extends StatefulWidget { /// /// * [value] determines this switch is on or off. /// * [onChanged] is called when the user toggles with switch on or off. - Switch({ + const Switch({ Key key, @required this.value, @required this.onChanged, @@ -137,7 +137,7 @@ class _SwitchState extends State with TickerProviderStateMixin { } class _SwitchRenderObjectWidget extends LeafRenderObjectWidget { - _SwitchRenderObjectWidget({ + const _SwitchRenderObjectWidget({ Key key, this.value, this.activeColor, diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index 9b54b018c7..81341f4c19 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'debug.dart'; class _AccountPictures extends StatelessWidget { - _AccountPictures({ + const _AccountPictures({ Key key, this.currentAccountPicture, this.otherAccountsPictures, @@ -49,7 +49,7 @@ class _AccountPictures extends StatelessWidget { } class _AccountDetails extends StatelessWidget { - _AccountDetails({ + const _AccountDetails({ Key key, @required this.accountName, @required this.accountEmail, @@ -132,7 +132,7 @@ class UserAccountsDrawerHeader extends StatefulWidget { /// Creates a material design drawer header. /// /// Requires one of its ancestors to be a [Material] widget. - UserAccountsDrawerHeader({ + const UserAccountsDrawerHeader({ Key key, this.decoration, this.margin: const EdgeInsets.only(bottom: 8.0), diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 863b5cbb3e..630c63f870 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -26,7 +26,7 @@ void main() { }, itemBuilder: (BuildContext context) { return >[ - new PopupMenuItem( + const PopupMenuItem( value: 1, child: const Text('One') ) diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index cf353e7584..2a02e775f5 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -13,10 +13,10 @@ void main() { testWidgets('LinearProgressIndicator(value: 0.0) can be constructed', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new SizedBox( + const Center( + child: const SizedBox( width: 200.0, - child: new LinearProgressIndicator(value: 0.0) + child: const LinearProgressIndicator(value: 0.0) ) ) ); @@ -24,10 +24,10 @@ void main() { testWidgets('LinearProgressIndicator(value: null) can be constructed', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new SizedBox( + const Center( + child: const SizedBox( width: 200.0, - child: new LinearProgressIndicator(value: null) + child: const LinearProgressIndicator(value: null) ) ) ); @@ -35,24 +35,24 @@ void main() { testWidgets('CircularProgressIndicator(value: 0.0) can be constructed', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new CircularProgressIndicator(value: 0.0) + const Center( + child: const CircularProgressIndicator(value: 0.0) ) ); }); testWidgets('CircularProgressIndicator(value: null) can be constructed', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new CircularProgressIndicator(value: null) + const Center( + child: const CircularProgressIndicator(value: null) ) ); }); testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async { - await tester.pumpWidget(new ListView(children: [new LinearProgressIndicator(value: 0.0)])); + await tester.pumpWidget(new ListView(children: [const LinearProgressIndicator(value: 0.0)])); final List layers1 = tester.layers; - await tester.pumpWidget(new ListView(children: [new LinearProgressIndicator(value: 0.5)])); + await tester.pumpWidget(new ListView(children: [const LinearProgressIndicator(value: 0.5)])); final List layers2 = tester.layers; expect(layers1, isNot(equals(layers2))); }); diff --git a/packages/flutter/test/material/theme_test.dart b/packages/flutter/test/material/theme_test.dart index 72bb05f4e3..3159bf58dc 100644 --- a/packages/flutter/test/material/theme_test.dart +++ b/packages/flutter/test/material/theme_test.dart @@ -25,7 +25,7 @@ void main() { key: popupMenuButtonKey, itemBuilder: (BuildContext context) { return >[ - new PopupMenuItem(child: const Text('menuItem')) + const PopupMenuItem(child: const Text('menuItem')) ]; } ), @@ -71,7 +71,7 @@ void main() { key: popupMenuButtonKey, itemBuilder: (BuildContext context) { return >[ - new PopupMenuItem(child: const Text('menuItem')) + const PopupMenuItem(child: const Text('menuItem')) ]; } ), diff --git a/packages/flutter/test/widgets/ticker_provider_test.dart b/packages/flutter/test/widgets/ticker_provider_test.dart index 177a1aff28..453989c929 100644 --- a/packages/flutter/test/widgets/ticker_provider_test.dart +++ b/packages/flutter/test/widgets/ticker_provider_test.dart @@ -9,7 +9,7 @@ void main() { testWidgets('TickerMode', (WidgetTester tester) async { final Widget widget = new TickerMode( enabled: false, - child: new LinearProgressIndicator() + child: const LinearProgressIndicator() ); expect(widget.toString, isNot(throwsException)); @@ -19,14 +19,14 @@ void main() { await tester.pumpWidget(new TickerMode( enabled: true, - child: new LinearProgressIndicator() + child: const LinearProgressIndicator() )); expect(tester.binding.transientCallbackCount, 1); await tester.pumpWidget(new TickerMode( enabled: false, - child: new LinearProgressIndicator() + child: const LinearProgressIndicator() )); expect(tester.binding.transientCallbackCount, 0); @@ -34,7 +34,7 @@ void main() { testWidgets('Navigation with TickerMode', (WidgetTester tester) async { await tester.pumpWidget(new MaterialApp( - home: new LinearProgressIndicator(), + home: const LinearProgressIndicator(), routes: { '/test': (BuildContext context) => const Text('hello'), },