diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index 3162c8c837..2075262c4a 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -176,9 +176,9 @@ class FancyImageItem extends StatelessWidget { new ItemDescription(), new ItemImageBox(), new InfoBar(), - new Padding( + const Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: new Divider() + child: const Divider() ), new IconBar(), new FatDivider() @@ -198,9 +198,9 @@ class FancyGalleryItem extends StatelessWidget { const UserHeader('Ali Connors'), new ItemGalleryBox(index), new InfoBar(), - new Padding( + const Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: new Divider() + child: const Divider() ), new IconBar(), new FatDivider() @@ -599,7 +599,7 @@ class GalleryDrawer extends StatelessWidget { onChanged: (bool value) { _changeTheme(context, value); }, ), ), - new Divider(), + const Divider(), new ListTile( leading: const Icon(Icons.hourglass_empty), title: const Text('Animate Slowly'), diff --git a/dev/manual_tests/card_collection.dart b/dev/manual_tests/card_collection.dart index a44cf15741..7d9636108e 100644 --- a/dev/manual_tests/card_collection.dart +++ b/dev/manual_tests/card_collection.dart @@ -93,20 +93,20 @@ class CardCollectionState extends State { buildDrawerCheckbox("Fixed size cards", _fixedSizeCards, _toggleFixedSizeCards), buildDrawerCheckbox("Let the sun shine", _sunshine, _toggleSunshine), buildDrawerCheckbox("Vary font sizes", _varyFontSizes, _toggleVaryFontSizes, enabled: !_editable), - new Divider(), + const Divider(), buildDrawerColorRadioItem("Deep Purple", Colors.deepPurple, _primaryColor, _selectColor), buildDrawerColorRadioItem("Green", Colors.green, _primaryColor, _selectColor), buildDrawerColorRadioItem("Amber", Colors.amber, _primaryColor, _selectColor), buildDrawerColorRadioItem("Teal", Colors.teal, _primaryColor, _selectColor), - new Divider(), + const Divider(), buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code), buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.endToStart, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back), buildDrawerDirectionRadioItem("Dismiss right", DismissDirection.startToEnd, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_forward), - new Divider(), + const Divider(), buildFontRadioItem("Left-align text", TextAlign.left, _textAlign, _changeTextAlign, icon: Icons.format_align_left, enabled: !_editable), buildFontRadioItem("Center-align text", TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable), buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable), - new Divider(), + const Divider(), new ListTile( leading: const Icon(Icons.dvr), onTap: () { debugDumpApp(); debugDumpRenderTree(); }, diff --git a/examples/flutter_gallery/lib/demo/animation/home.dart b/examples/flutter_gallery/lib/demo/animation/home.dart index 721f7401c8..e86c6936d6 100644 --- a/examples/flutter_gallery/lib/demo/animation/home.dart +++ b/examples/flutter_gallery/lib/demo/animation/home.dart @@ -525,7 +525,7 @@ class _AnimationDemoHomeState extends State { new Positioned( top: statusBarHeight, left: 0.0, - child: new IconTheme( + child: const IconTheme( data: const IconThemeData(color: Colors.white), child: const BackButton(), ), diff --git a/examples/flutter_gallery/lib/demo/calculator/home.dart b/examples/flutter_gallery/lib/demo/calculator/home.dart index 6ace8b9648..093804be2a 100644 --- a/examples/flutter_gallery/lib/demo/calculator/home.dart +++ b/examples/flutter_gallery/lib/demo/calculator/home.dart @@ -126,7 +126,7 @@ class _CalculatorState extends State { flex: 2, child: new CalcDisplay(content: _expression.toString()) ), - new Divider(height: 1.0), + const Divider(height: 1.0), new Expanded( flex: 3, child: new KeyPad(calcState: this) diff --git a/examples/flutter_gallery/lib/demo/contacts_demo.dart b/examples/flutter_gallery/lib/demo/contacts_demo.dart index fdc55502a3..95daa37b60 100644 --- a/examples/flutter_gallery/lib/demo/contacts_demo.dart +++ b/examples/flutter_gallery/lib/demo/contacts_demo.dart @@ -116,7 +116,7 @@ class ContactsDemoState extends State { icon: const Icon(Icons.create), tooltip: 'Edit', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('This is actually just a demo. Editing isn\'t supported.') )); }, @@ -176,7 +176,7 @@ class ContactsDemoState extends State { icon: Icons.message, tooltip: 'Send message', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('Pretend that this opened your SMS application.') )); }, @@ -189,7 +189,7 @@ class ContactsDemoState extends State { icon: Icons.message, tooltip: 'Send message', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('In this demo, this button doesn\'t do anything.') )); }, @@ -202,7 +202,7 @@ class ContactsDemoState extends State { icon: Icons.message, tooltip: 'Send message', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('Imagine if you will, a messaging application.') )); }, @@ -220,7 +220,7 @@ class ContactsDemoState extends State { icon: Icons.email, tooltip: 'Send personal e-mail', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('Here, your e-mail application would open.') )); }, @@ -233,7 +233,7 @@ class ContactsDemoState extends State { icon: Icons.email, tooltip: 'Send work e-mail', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('This is a demo, so this button does not actually work.') )); }, @@ -251,7 +251,7 @@ class ContactsDemoState extends State { icon: Icons.map, tooltip: 'Open map', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('This would show a map of San Francisco.') )); }, @@ -265,7 +265,7 @@ class ContactsDemoState extends State { icon: Icons.map, tooltip: 'Open map', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('This would show a map of Mountain View.') )); }, @@ -279,7 +279,7 @@ class ContactsDemoState extends State { icon: Icons.map, tooltip: 'Open map', onPressed: () { - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('This would also show a map, if this was not a demo.') )); }, diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart index bcd717ff7e..57b100c2f8 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart @@ -14,8 +14,8 @@ class CupertinoProgressIndicatorDemo extends StatelessWidget { appBar: new AppBar( title: const Text('Cupertino Activity Indicator'), ), - body: new Center( - child: new CupertinoActivityIndicator(), + body: const Center( + child: const CupertinoActivityIndicator(), ), ); } diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart index 79685ecdc8..cbc6d7bccf 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart @@ -49,7 +49,7 @@ class _CupertinoButtonDemoState extends State { setState(() {_pressedCount++;}); } ), - new CupertinoButton( + const CupertinoButton( child: const Text('Disabled'), onPressed: null, ), @@ -65,7 +65,7 @@ class _CupertinoButtonDemoState extends State { } ), const Padding(padding: const EdgeInsets.all(12.0)), - new CupertinoButton( + const CupertinoButton( child: const Text('Disabled'), color: _kBlue, onPressed: null, diff --git a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart index 92fdadc505..249b2457cf 100644 --- a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart @@ -121,7 +121,7 @@ class _ButtonsDemoState extends State { // Perform some action }, ), - new FlatButton( + const FlatButton( child: const Text('DISABLED'), onPressed: null, ) diff --git a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart index b92235593d..2647c7727d 100644 --- a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart @@ -67,7 +67,7 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { void _showNotImplementedMessage() { Navigator.of(context).pop(); // Dismiss the drawer. - _scaffoldKey.currentState.showSnackBar(new SnackBar( + _scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text("The drawer's items don't do anything") )); } diff --git a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart index e08d2da649..2a0e339e8f 100644 --- a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart @@ -108,7 +108,7 @@ class CollapsibleBody extends StatelessWidget { ) ) ), - new Divider(height: 1.0), + const Divider(height: 1.0), new Container( padding: const EdgeInsets.symmetric(vertical: 16.0), child: new Row( 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 d616a06873..925ce96dcc 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -103,13 +103,13 @@ class LeaveBehindDemoState extends State { }, background: new Container( color: theme.primaryColor, - child: new ListTile( + child: const ListTile( leading: const Icon(Icons.delete, color: Colors.white, size: 36.0) ) ), secondaryBackground: new Container( color: theme.primaryColor, - child: new ListTile( + child: const ListTile( trailing: const Icon(Icons.archive, color: Colors.white, size: 36.0) ) ), diff --git a/examples/flutter_gallery/lib/demo/material/menu_demo.dart b/examples/flutter_gallery/lib/demo/material/menu_demo.dart index 44035fc0f1..6c49b8411c 100644 --- a/examples/flutter_gallery/lib/demo/material/menu_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/menu_demo.dart @@ -119,31 +119,31 @@ class MenuDemoState extends State { padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + const PopupMenuItem( value: 'Preview', - child: new ListTile( + child: const ListTile( leading: const Icon(Icons.visibility), title: const Text('Preview') ) ), - new PopupMenuItem( + const PopupMenuItem( value: 'Share', - child: new ListTile( + child: const ListTile( leading: const Icon(Icons.person_add), title: const Text('Share') ) ), - new PopupMenuItem( + const PopupMenuItem( value: 'Get Link', - child: new ListTile( + child: const ListTile( leading: const Icon(Icons.link), title: const Text('Get link') ) ), const PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771 - new PopupMenuItem( + const PopupMenuItem( value: 'Remove', - child: new ListTile( + child: const ListTile( leading: const Icon(Icons.delete), title: const Text('Remove') ) diff --git a/examples/flutter_gallery/lib/demo/material/slider_demo.dart b/examples/flutter_gallery/lib/demo/material/slider_demo.dart index acd8d00fb5..7441d67d3d 100644 --- a/examples/flutter_gallery/lib/demo/material/slider_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/slider_demo.dart @@ -43,7 +43,7 @@ class _SliderDemoState extends State { new Column( mainAxisSize: MainAxisSize.min, children: [ - new Slider(value: 0.25, thumbOpenAtMin: true, onChanged: null), + const Slider(value: 0.25, thumbOpenAtMin: true, onChanged: null), const Text('Disabled'), ] ), diff --git a/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart b/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart index a6d025d910..c7bd7f3e01 100644 --- a/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart @@ -46,7 +46,7 @@ class TooltipDemo extends StatelessWidget { color: theme.iconTheme.color, tooltip: 'Place a phone call', onPressed: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(const SnackBar( content: const Text('That was an ordinary tap.') )); } diff --git a/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart b/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart index d15217327d..cc22f96578 100644 --- a/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart @@ -14,19 +14,19 @@ class TwoLevelListDemo extends StatelessWidget { body: new TwoLevelList( type: MaterialListType.oneLine, children: [ - new TwoLevelListItem(title: const Text('Top')), + const TwoLevelListItem(title: const Text('Top')), new TwoLevelSublist( title: const Text('Sublist'), backgroundColor: Theme.of(context).accentColor.withOpacity(0.025), children: [ - new TwoLevelListItem(title: const Text('One')), - new TwoLevelListItem(title: const Text('Two')), + const TwoLevelListItem(title: const Text('One')), + const TwoLevelListItem(title: const Text('Two')), // https://en.wikipedia.org/wiki/Free_Four - new TwoLevelListItem(title: const Text('Free')), - new TwoLevelListItem(title: const Text('Four')) + const TwoLevelListItem(title: const Text('Free')), + const TwoLevelListItem(title: const Text('Four')) ] ), - new TwoLevelListItem(title: const Text('Bottom')) + const TwoLevelListItem(title: const Text('Bottom')) ] ) ); diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index ab4d4e39b5..b56232a8be 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart @@ -84,7 +84,7 @@ class _RecipeGridPageState extends State { floatingActionButton: new FloatingActionButton( child: const Icon(Icons.edit), onPressed: () { - scaffoldKey.currentState.showSnackBar(new SnackBar( + scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('Not supported.'), )); }, @@ -108,7 +108,7 @@ class _RecipeGridPageState extends State { icon: const Icon(Icons.search), tooltip: 'Search', onPressed: () { - scaffoldKey.currentState.showSnackBar(new SnackBar( + scaffoldKey.currentState.showSnackBar(const SnackBar( content: const Text('Not supported.'), )); }, diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart index d6842cb4e3..6a45a1aced 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart @@ -82,7 +82,7 @@ class ShrinePageState extends State { void _emptyCart() { widget.shoppingCart.clear(); - widget.scaffoldKey.currentState.showSnackBar(new SnackBar(content: const Text('Shopping cart is empty'))); + widget.scaffoldKey.currentState.showSnackBar(const SnackBar(content: const Text('Shopping cart is empty'))); } @override diff --git a/examples/flutter_gallery/lib/gallery/drawer.dart b/examples/flutter_gallery/lib/gallery/drawer.dart index 1070df9fd2..92f765b6d7 100644 --- a/examples/flutter_gallery/lib/gallery/drawer.dart +++ b/examples/flutter_gallery/lib/gallery/drawer.dart @@ -254,10 +254,10 @@ class GalleryDrawer extends StatelessWidget { new GalleryDrawerHeader(light: useLightTheme), lightThemeItem, darkThemeItem, - new Divider(), + const Divider(), mountainViewItem, cupertinoItem, - new Divider(), + const Divider(), animateSlowlyItem, // index 8, optional: Performance Overlay sendFeedbackItem, diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index 1070cd4008..97d22eb407 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -44,7 +44,7 @@ new FlatButton( // Create a disabled button. // Buttons are disabled when onPressed isn't // specified or is null. -new FlatButton( +const FlatButton( child: const Text('BUTTON TITLE'), onPressed: null ); diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index 5dd6d5c458..a2a4e411bd 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -132,7 +132,7 @@ class GalleryHomeState extends State with SingleTickerProviderState for (GalleryItem galleryItem in kAllGalleryItems) { if (category != galleryItem.category) { if (category != null) - listItems.add(new Divider()); + listItems.add(const Divider()); listItems.add( new Container( height: 48.0, @@ -166,7 +166,7 @@ class GalleryHomeState extends State with SingleTickerProviderState ), body: new CustomScrollView( slivers: [ - new SliverAppBar( + const SliverAppBar( pinned: true, expandedHeight: _kFlexibleSpaceMaxHeight, flexibleSpace: const FlexibleSpaceBar( diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 11a87c67fe..178304adf6 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -118,12 +118,12 @@ class StockHomeState extends State { child: new ListView( children: [ const DrawerHeader(child: const Center(child: const Text('Stocks'))), - new ListTile( + const ListTile( leading: const Icon(Icons.assessment), title: const Text('Stock List'), selected: true, ), - new ListTile( + const ListTile( leading: const Icon(Icons.account_balance), title: const Text('Account Balance'), enabled: false, @@ -142,7 +142,7 @@ class StockHomeState extends State { } }, ), - new Divider(), + const Divider(), new ListTile( leading: const Icon(Icons.thumb_up), title: const Text('Optimistic'), @@ -167,7 +167,7 @@ class StockHomeState extends State { _handleStockModeChange(StockMode.pessimistic); }, ), - new Divider(), + const Divider(), new ListTile( leading: const Icon(Icons.settings), title: const Text('Settings'), diff --git a/packages/flutter/lib/src/cupertino/activity_indicator.dart b/packages/flutter/lib/src/cupertino/activity_indicator.dart index b624f90219..e978abafc3 100644 --- a/packages/flutter/lib/src/cupertino/activity_indicator.dart +++ b/packages/flutter/lib/src/cupertino/activity_indicator.dart @@ -13,12 +13,11 @@ import 'package:flutter/widgets.dart'; /// * class CupertinoActivityIndicator extends StatefulWidget { /// Creates an iOS-style activity indicator. - CupertinoActivityIndicator({ + const CupertinoActivityIndicator({ Key key, this.animating: true, - }) : super(key: key) { - assert(animating != null); - } + }) : assert(animating != null), + super(key: key); /// Whether the activity indicator is running its animation. /// diff --git a/packages/flutter/lib/src/cupertino/button.dart b/packages/flutter/lib/src/cupertino/button.dart index acc1cd001f..24ddf1b262 100644 --- a/packages/flutter/lib/src/cupertino/button.dart +++ b/packages/flutter/lib/src/cupertino/button.dart @@ -42,16 +42,14 @@ const EdgeInsets _kBackgroundButtonPadding = /// * class CupertinoButton extends StatefulWidget { /// Creates an iOS-style button. - CupertinoButton({ + const CupertinoButton({ @required this.child, this.padding, this.color, this.minSize: 44.0, this.pressedOpacity: 0.1, @required this.onPressed, - }) { - assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0); - } + }) : assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0); /// The widget below this widget in the tree. /// diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index a6e6851fb9..f0e130ee8f 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -177,13 +177,11 @@ const Color _kDestructiveActionColor = const Color(0xFFFF3B30); /// * [CupertinoAlertDialog] class CupertinoDialogAction extends StatelessWidget { /// Creates an action for an iOS-style dialog. - CupertinoDialogAction({ + const CupertinoDialogAction({ this.onPressed, this.isDestructive: false, @required this.child, - }) { - assert(child != null); - } + }) : assert(child != null); /// The callback that is called when the button is tapped or otherwise activated. /// diff --git a/packages/flutter/lib/src/cupertino/slider.dart b/packages/flutter/lib/src/cupertino/slider.dart index 5853ac3dd7..7cf8bb2dc2 100644 --- a/packages/flutter/lib/src/cupertino/slider.dart +++ b/packages/flutter/lib/src/cupertino/slider.dart @@ -41,7 +41,7 @@ class CupertinoSlider extends StatefulWidget { /// /// * [value] determines currently selected value for this slider. /// * [onChanged] is called when the user selects a new value for the slider. - CupertinoSlider({ + const CupertinoSlider({ Key key, @required this.value, @required this.onChanged, @@ -49,13 +49,12 @@ class CupertinoSlider extends StatefulWidget { this.max: 1.0, this.divisions, this.activeColor: const Color(0xFF027AFF), - }) : super(key: key) { - assert(value != null); - assert(min != null); - assert(max != null); - assert(value >= min && value <= max); - assert(divisions == null || divisions > 0); - } + }) : assert(value != null), + assert(min != null), + assert(max != null), + assert(value >= min && value <= max), + assert(divisions == null || divisions > 0), + super(key: key); /// The currently selected value for this slider. /// diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index f1b9354fd8..22327996e7 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -677,7 +677,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { /// * class SliverAppBar extends StatefulWidget { /// Creates a material design app bar that can be placed in a [CustomScrollView]. - SliverAppBar({ + const SliverAppBar({ Key key, this.leading, this.title, @@ -695,13 +695,12 @@ class SliverAppBar extends StatefulWidget { this.floating: false, this.pinned: false, this.snap: false, - }) : super(key: key) { - assert(primary != null); - assert(floating != null); - assert(pinned != null); - assert(pinned && floating ? bottom != null : true); - assert(snap != null); - } + }) : assert(primary != null), + assert(floating != null), + assert(pinned != null), + assert(pinned && floating ? bottom != null : true), + assert(snap != null), + super(key: key); /// A widget to display before the [title]. /// diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index d298034c12..75bad9760d 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -47,15 +47,14 @@ class BottomSheet extends StatefulWidget { /// Typically, bottom sheets are created implicitly by /// [Scaffold.showBottomSheet], for persistent bottom sheets, or by /// [showModalBottomSheet], for modal bottom sheets. - BottomSheet({ + const BottomSheet({ Key key, this.animationController, @required this.onClosing, @required this.builder - }) : super(key: key) { - assert(onClosing != null); - assert(builder != null); - } + }) : assert(onClosing != null), + assert(builder != null), + super(key: key); /// The animation that controls the bottom sheet's position. /// diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index 35c719c184..cfdd7c309f 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -103,19 +103,18 @@ class _CheckboxState extends State with TickerProviderStateMixin { } class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget { - _CheckboxRenderObjectWidget({ + const _CheckboxRenderObjectWidget({ Key key, @required this.value, @required this.activeColor, @required this.inactiveColor, @required this.onChanged, @required this.vsync, - }) : super(key: key) { - assert(value != null); - assert(activeColor != null); - assert(inactiveColor != null); - assert(vsync != null); - } + }) : assert(value != null), + assert(activeColor != null), + assert(inactiveColor != null), + assert(vsync != null), + super(key: key); final bool value; final Color activeColor; diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 73e0150e66..bfec061650 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -44,17 +44,16 @@ const double _kDatePickerLandscapeHeight = _kMaxDayPickerHeight + _kDialogAction // Shows the selected date in large font and toggles between year and day mode class _DatePickerHeader extends StatelessWidget { - _DatePickerHeader({ + const _DatePickerHeader({ Key key, @required this.selectedDate, @required this.mode, @required this.onModeChanged, @required this.orientation, - }) : super(key: key) { - assert(selectedDate != null); - assert(mode != null); - assert(orientation != null); - } + }) : assert(selectedDate != null), + assert(mode != null), + assert(orientation != null), + super(key: key); final DateTime selectedDate; final _DatePickerMode mode; diff --git a/packages/flutter/lib/src/material/divider.dart b/packages/flutter/lib/src/material/divider.dart index 99d54f3566..b729f4fd06 100644 --- a/packages/flutter/lib/src/material/divider.dart +++ b/packages/flutter/lib/src/material/divider.dart @@ -27,14 +27,13 @@ class Divider extends StatelessWidget { /// Creates a material design divider. /// /// The height must be at least 1.0 logical pixels. - Divider({ + const Divider({ Key key, this.height: 16.0, this.indent: 0.0, this.color - }) : super(key: key) { - assert(height >= 1.0); - } + }) : assert(height >= 1.0), + super(key: key); /// The divider's vertical extent. /// diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index 8c96fb3fb4..9288f1f872 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -116,12 +116,11 @@ class DrawerController extends StatefulWidget { /// Rarely used directly. /// /// The [child] argument must not be null and is typically a [Drawer]. - DrawerController({ + const DrawerController({ GlobalKey key, @required this.child - }) : super(key: key) { - assert(child != null); - } + }) : assert(child != null), + super(key: key); /// The widget below this widget in the tree. /// diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 48f06928b2..03cacbd6e8 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -333,13 +333,12 @@ class DropdownMenuItem extends StatelessWidget { /// Creates an item for a dropdown menu. /// /// The [child] argument is required. - DropdownMenuItem({ + const DropdownMenuItem({ Key key, this.value, @required this.child, - }) : super(key: key) { - assert(child != null); - } + }) : assert(child != null), + super(key: key); /// The widget below this widget in the tree. /// @@ -370,12 +369,11 @@ class DropdownMenuItem extends StatelessWidget { class DropdownButtonHideUnderline extends InheritedWidget { /// Creates a [DropdownButtonHideUnderline]. A non-null [child] must /// be given. - DropdownButtonHideUnderline({ + const DropdownButtonHideUnderline({ Key key, @required Widget child, - }) : super(key: key, child: child) { - assert(child != null); - } + }) : assert(child != null), + super(key: key, child: child); /// Returns whether the underline of [DropdownButton] widgets should /// be hidden. diff --git a/packages/flutter/lib/src/material/expand_icon.dart b/packages/flutter/lib/src/material/expand_icon.dart index ade426e36b..b5fd7aaafc 100644 --- a/packages/flutter/lib/src/material/expand_icon.dart +++ b/packages/flutter/lib/src/material/expand_icon.dart @@ -21,17 +21,16 @@ import 'theme.dart'; class ExpandIcon extends StatefulWidget { /// Creates an [ExpandIcon] with the given padding, and a callback that is /// triggered when the icon is pressed. - ExpandIcon({ + const ExpandIcon({ Key key, this.isExpanded: false, this.size: 24.0, @required this.onPressed, this.padding: const EdgeInsets.all(8.0) - }) : super(key: key) { - assert(isExpanded != null); - assert(size != null); - assert(padding != null); - } + }) : assert(isExpanded != null), + assert(size != null), + assert(padding != null), + super(key: key); /// Whether the icon is in an expanded state. /// diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index e55be3ed73..2b8a40aa57 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -73,15 +73,14 @@ class ExpansionPanel { class ExpansionPanelList extends StatelessWidget { /// Creates an expansion panel list widget. The [expansionCallback] is /// triggered when an expansion panel expand/collapse button is pushed. - ExpansionPanelList({ + const ExpansionPanelList({ Key key, this.children: const [], this.expansionCallback, this.animationDuration: kThemeAnimationDuration - }) : super(key: key) { - assert(children != null); - assert(animationDuration != null); - } + }) : assert(children != null), + assert(animationDuration != null), + super(key: key); /// The children of the expansion panel list. They are layed in a similar /// fashion to [ListBody]. diff --git a/packages/flutter/lib/src/material/flat_button.dart b/packages/flutter/lib/src/material/flat_button.dart index 9ef27c688f..9207b1fcb9 100644 --- a/packages/flutter/lib/src/material/flat_button.dart +++ b/packages/flutter/lib/src/material/flat_button.dart @@ -47,7 +47,7 @@ class FlatButton extends StatelessWidget { /// /// The [child] argument is required and is typically a [Text] widget in all /// caps. - FlatButton({ + const FlatButton({ Key key, @required this.onPressed, this.textColor, @@ -59,9 +59,8 @@ class FlatButton extends StatelessWidget { this.textTheme, this.colorBrightness, @required this.child - }) : super(key: key) { - assert(child != null); - } + }) : assert(child != null), + super(key: key); /// The callback that is called when the button is tapped or otherwise activated. /// diff --git a/packages/flutter/lib/src/material/grid_tile.dart b/packages/flutter/lib/src/material/grid_tile.dart index 8cf273ab60..ff2a060d0f 100644 --- a/packages/flutter/lib/src/material/grid_tile.dart +++ b/packages/flutter/lib/src/material/grid_tile.dart @@ -21,14 +21,13 @@ class GridTile extends StatelessWidget { /// Creates a grid tile. /// /// Must have a child. Does not typically have both a header and a footer. - GridTile({ + const GridTile({ Key key, this.header, this.footer, @required this.child, - }) : super(key: key) { - assert(child != null); - } + }) : assert(child != null), + super(key: key); /// The widget to show over the top of this grid tile. /// diff --git a/packages/flutter/lib/src/material/icon_theme.dart b/packages/flutter/lib/src/material/icon_theme.dart index bdc63993db..65c8b66b64 100644 --- a/packages/flutter/lib/src/material/icon_theme.dart +++ b/packages/flutter/lib/src/material/icon_theme.dart @@ -16,14 +16,13 @@ class IconTheme extends InheritedWidget { /// descendant widgets. /// /// Both [data] and [child] arguments must not be null. - IconTheme({ + const IconTheme({ Key key, @required this.data, @required Widget child - }) : super(key: key, child: child) { - assert(data != null); - assert(child != null); - } + }) : assert(data != null), + assert(child != null), + super(key: key, child: child); /// Creates an icon theme that controls the color, opacity, and size of /// descendant widgets, and merges in the current icon theme, if any. diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 5b053cc1c5..bea214ad07 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -463,15 +463,14 @@ class InputDecorator extends StatelessWidget { // Smoothly animate the label of an InputDecorator as the label // transitions between inline and caption. class _AnimatedLabel extends ImplicitlyAnimatedWidget { - _AnimatedLabel({ + const _AnimatedLabel({ Key key, this.text, @required this.style, Curve curve: Curves.linear, @required Duration duration, - }) : super(key: key, curve: curve, duration: duration) { - assert(style != null); - } + }) : assert(style != null), + super(key: key, curve: curve, duration: duration); final String text; final TextStyle style; diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 18af24672d..15fd77b791 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -158,7 +158,7 @@ class ListTile extends StatelessWidget { /// If [isThreeLine] is true, then [subtitle] must not be null. /// /// Requires one of its ancestors to be a [Material] widget. - ListTile({ + const ListTile({ Key key, this.leading, this.title, @@ -170,11 +170,10 @@ class ListTile extends StatelessWidget { this.onTap, this.onLongPress, this.selected: false, - }) : super(key: key) { - assert(isThreeLine != null); - assert(enabled != null); - assert(selected != null); - } + }) : assert(isThreeLine != null), + assert(enabled != null), + assert(selected != null), + super(key: key); /// A widget to display before the title. /// diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index 2c4bb362eb..c6dece98bd 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -110,7 +110,7 @@ class Material extends StatefulWidget { /// Creates a piece of material. /// /// The [type] and the [elevation] arguments must not be null. - Material({ + const Material({ Key key, this.type: MaterialType.canvas, this.elevation: 0, @@ -118,11 +118,10 @@ class Material extends StatefulWidget { this.textStyle, this.borderRadius, this.child, - }) : super(key: key) { - assert(type != null); - assert(elevation != null); - assert(type != MaterialType.circle || borderRadius == null); - } + }) : assert(type != null), + assert(elevation != null), + assert(!(identical(type, MaterialType.circle) && borderRadius != null)), + super(key: key); /// The widget below this widget in the tree. final Widget child; diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index 0394606a3e..1aa440cff2 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -34,12 +34,11 @@ abstract class MergeableMaterialItem { class MaterialSlice extends MergeableMaterialItem { /// Creates a slice of [Material] that's mergeable within a /// [MergeableMaterial]. - MaterialSlice({ + const MaterialSlice({ @required LocalKey key, @required this.child, - }) : super(key) { - assert(key != null); - } + }) : assert(key != null), + super(key); /// The contents of this slice. final Widget child; @@ -55,12 +54,11 @@ class MaterialSlice extends MergeableMaterialItem { /// All [MaterialGap] objects need a [LocalKey]. class MaterialGap extends MergeableMaterialItem { /// Creates a Material gap with a given size. - MaterialGap({ + const MaterialGap({ @required LocalKey key, this.size: 16.0 - }) : super(key) { - assert(key != null); - } + }) : assert(key != null), + super(key); /// The main axis extent of this gap. For example, if the [MergableMaterial] /// is vertical, then this is the height of the gap. diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 110da6d3b1..6d2fab8e75 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -475,7 +475,7 @@ class PopupMenuButton extends StatefulWidget { /// Creates a button that shows a popup menu. /// /// The [itemBuilder] argument must not be null. - PopupMenuButton({ + const PopupMenuButton({ Key key, @required this.itemBuilder, this.initialValue, @@ -484,9 +484,8 @@ class PopupMenuButton extends StatefulWidget { this.elevation: 8, this.padding: const EdgeInsets.all(8.0), this.child - }) : super(key: key) { - assert(itemBuilder != null); - } + }) : assert(itemBuilder != null), + super(key: key); /// Called when the button is pressed to create the items to show in the menu. final PopupMenuItemBuilder itemBuilder; diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index ccb636143f..55e7ce37ac 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -127,19 +127,18 @@ class _RadioState extends State> with TickerProviderStateMixin { } class _RadioRenderObjectWidget extends LeafRenderObjectWidget { - _RadioRenderObjectWidget({ + const _RadioRenderObjectWidget({ Key key, @required this.selected, @required this.activeColor, @required this.inactiveColor, this.onChanged, @required this.vsync, - }) : super(key: key) { - assert(selected != null); - assert(activeColor != null); - assert(inactiveColor != null); - assert(vsync != null); - } + }) : assert(selected != null), + assert(activeColor != null), + assert(inactiveColor != null), + assert(vsync != null), + super(key: key); final bool selected; final Color inactiveColor; diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 71f2478257..56651187be 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -80,17 +80,16 @@ class RefreshIndicator extends StatefulWidget { /// /// The [onRefresh] and [child] arguments must be non-null. The default /// [displacement] is 40.0 logical pixels. - RefreshIndicator({ + const RefreshIndicator({ Key key, @required this.child, this.displacement: 40.0, @required this.onRefresh, this.color, this.backgroundColor - }) : super(key: key) { - assert(child != null); - assert(onRefresh != null); - } + }) : assert(child != null), + assert(onRefresh != null), + super(key: key); /// The refresh indicator will be stacked on top of this child. The indicator /// will appear when child's Scrollable descendant is over-scrolled. diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 885802c9fa..0b0fd9c9ae 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -1015,12 +1015,11 @@ class PersistentBottomSheetController extends ScaffoldFeatureController<_Pers } class _ScaffoldScope extends InheritedWidget { - _ScaffoldScope({ + const _ScaffoldScope({ @required this.hasDrawer, @required Widget child, - }) : super(child: child) { - assert(hasDrawer != null); - } + }) : assert(hasDrawer != null), + super(child: child); final bool hasDrawer; diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index a4cb5d5cf3..64fec7f4fc 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -49,7 +49,7 @@ class Slider extends StatefulWidget { /// /// * [value] determines currently selected value for this slider. /// * [onChanged] is called when the user selects a new value for the slider. - Slider({ + const Slider({ Key key, @required this.value, @required this.onChanged, @@ -59,14 +59,13 @@ class Slider extends StatefulWidget { this.label, this.activeColor, this.thumbOpenAtMin: false, - }) : super(key: key) { - assert(value != null); - assert(min != null); - assert(max != null); - assert(value >= min && value <= max); - assert(divisions == null || divisions > 0); - assert(thumbOpenAtMin != null); - } + }) : assert(value != null), + assert(min != null), + assert(max != null), + assert(value >= min && value <= max), + assert(divisions == null || divisions > 0), + assert(thumbOpenAtMin != null), + super(key: key); /// The currently selected value for this slider. /// diff --git a/packages/flutter/lib/src/material/snack_bar.dart b/packages/flutter/lib/src/material/snack_bar.dart index bdf4836154..a0eb8c9c33 100644 --- a/packages/flutter/lib/src/material/snack_bar.dart +++ b/packages/flutter/lib/src/material/snack_bar.dart @@ -79,14 +79,13 @@ class SnackBarAction extends StatefulWidget { /// Creates an action for a [SnackBar]. /// /// The [label] and [onPressed] arguments must be non-null. - SnackBarAction({ + const SnackBarAction({ Key key, @required this.label, @required this.onPressed - }) : super(key: key) { - assert(label != null); - assert(onPressed != null); - } + }) : assert(label != null), + assert(onPressed != null), + super(key: key); /// The button label. final String label; @@ -145,16 +144,15 @@ class SnackBar extends StatelessWidget { /// Creates a snack bar. /// /// The [content] argument must be non-null. - SnackBar({ + const SnackBar({ Key key, @required this.content, this.backgroundColor, this.action, this.duration: _kSnackBarDisplayDuration, this.animation, - }) : super(key: key) { - assert(content != null); - } + }) : assert(content != null), + super(key: key); /// The primary content of the snack bar. /// diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 74a63824e5..217f4f1621 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -80,17 +80,15 @@ class Step { /// Creates a step for a [Stepper]. /// /// The [title], [content], and [state] arguments must not be null. - Step({ + const Step({ @required this.title, this.subtitle, @required this.content, this.state: StepState.indexed, this.isActive: false, - }) { - assert(title != null); - assert(content != null); - assert(state != null); - } + }) : assert(title != null), + assert(content != null), + assert(state != null); /// The title of the step that typically describes it. final Widget title; diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index e4baaaf790..6480ad8214 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -39,13 +39,12 @@ const EdgeInsets _kTabLabelPadding = const EdgeInsets.symmetric(horizontal: 12.0 class Tab extends StatelessWidget { /// Creates a material design [TabBar] tab. At least one of [text] and [icon] /// must be non-null. - Tab({ + const Tab({ Key key, this.text, this.icon, - }) : super(key: key) { - assert(text != null || icon != null); - } + }) : assert(text != null || icon != null), + super(key: key); /// The text to display as the tab's label. final String text; diff --git a/packages/flutter/lib/src/material/theme.dart b/packages/flutter/lib/src/material/theme.dart index edf56cde71..8ee93ea099 100644 --- a/packages/flutter/lib/src/material/theme.dart +++ b/packages/flutter/lib/src/material/theme.dart @@ -31,15 +31,14 @@ class Theme extends InheritedWidget { /// Applies the given theme [data] to [child]. /// /// The [data] and [child] arguments must not be null. - Theme({ + const Theme({ Key key, @required this.data, this.isMaterialAppTheme: false, @required Widget child - }) : super(key: key, child: child) { - assert(child != null); - assert(data != null); - } + }) : assert(child != null), + assert(data != null), + super(key: key, child: child); /// Specifies the color and typography values for descendant widgets. final ThemeData data; @@ -154,17 +153,16 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget { /// /// By default, the theme transition uses a linear curve. The [data] and /// [child] arguments must not be null. - AnimatedTheme({ + const AnimatedTheme({ Key key, @required this.data, this.isMaterialAppTheme: false, Curve curve: Curves.linear, Duration duration: kThemeAnimationDuration, @required this.child, - }) : super(key: key, curve: curve, duration: duration) { - assert(child != null); - assert(data != null); - } + }) : assert(child != null), + assert(data != null), + super(key: key, curve: curve, duration: duration); /// Specifies the color and typography values for descendant widgets. final ThemeData data; diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index d14f44ae12..53ccd4a29d 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -184,7 +184,7 @@ class ThemeData { /// This will rarely be used directly. It is used by [lerp] to /// create intermediate themes based on two themes created with the /// [new ThemeData] constructor. - ThemeData.raw({ + const ThemeData.raw({ @required this.brightness, @required this.primaryColor, @required this.primaryColorBrightness, @@ -215,38 +215,36 @@ class ThemeData { @required this.primaryIconTheme, @required this.accentIconTheme, @required this.platform - }) { - assert(brightness != null); - assert(primaryColor != null); - assert(primaryColorBrightness != null); - assert(accentColor != null); - assert(accentColorBrightness != null); - assert(canvasColor != null); - assert(scaffoldBackgroundColor != null); - assert(cardColor != null); - assert(dividerColor != null); - assert(highlightColor != null); - assert(splashColor != null); - assert(selectedRowColor != null); - assert(unselectedWidgetColor != null); - assert(disabledColor != null); - assert(buttonColor != null); - assert(secondaryHeaderColor != null); - assert(textSelectionColor != null); - assert(textSelectionHandleColor != null); - assert(backgroundColor != null); - assert(dialogBackgroundColor != null); - assert(indicatorColor != null); - assert(hintColor != null); - assert(errorColor != null); - assert(textTheme != null); - assert(primaryTextTheme != null); - assert(accentTextTheme != null); - assert(iconTheme != null); - assert(primaryIconTheme != null); - assert(accentIconTheme != null); - assert(platform != null); - } + }) : assert(brightness != null), + assert(primaryColor != null), + assert(primaryColorBrightness != null), + assert(accentColor != null), + assert(accentColorBrightness != null), + assert(canvasColor != null), + assert(scaffoldBackgroundColor != null), + assert(cardColor != null), + assert(dividerColor != null), + assert(highlightColor != null), + assert(splashColor != null), + assert(selectedRowColor != null), + assert(unselectedWidgetColor != null), + assert(disabledColor != null), + assert(buttonColor != null), + assert(secondaryHeaderColor != null), + assert(textSelectionColor != null), + assert(textSelectionHandleColor != null), + assert(backgroundColor != null), + assert(dialogBackgroundColor != null), + assert(indicatorColor != null), + assert(hintColor != null), + assert(errorColor != null), + assert(textTheme != null), + assert(primaryTextTheme != null), + assert(accentTextTheme != null), + assert(iconTheme != null), + assert(primaryIconTheme != null), + assert(accentIconTheme != null), + assert(platform != null); /// A default light blue theme. factory ThemeData.light() => new ThemeData(brightness: Brightness.light); diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index d4269f45c9..bb3b6ec99a 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -207,17 +207,15 @@ class _TimePickerHeaderLayout extends MultiChildLayoutDelegate { // TODO(ianh): Localize! class _TimePickerHeader extends StatelessWidget { - _TimePickerHeader({ + const _TimePickerHeader({ @required this.selectedTime, @required this.mode, @required this.orientation, @required this.onModeChanged, @required this.onChanged, - }) { - assert(selectedTime != null); - assert(mode != null); - assert(orientation != null); - } + }) : assert(selectedTime != null), + assert(mode != null), + assert(orientation != null); final TimeOfDay selectedTime; final _TimePickerMode mode; @@ -447,13 +445,11 @@ class _DialPainter extends CustomPainter { } class _Dial extends StatefulWidget { - _Dial({ + const _Dial({ @required this.selectedTime, @required this.mode, @required this.onChanged - }) { - assert(selectedTime != null); - } + }) : assert(selectedTime != null); final TimeOfDay selectedTime; final _TimePickerMode mode; @@ -625,12 +621,11 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { } class _TimePickerDialog extends StatefulWidget { - _TimePickerDialog({ + const _TimePickerDialog({ Key key, @required this.initialTime - }) : super(key: key) { - assert(initialTime != null); - } + }) : assert(initialTime != null), + super(key: key); final TimeOfDay initialTime; diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 0778544911..1f71cfcbfd 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -41,7 +41,7 @@ class Tooltip extends StatefulWidget { /// user long presses on the widget. /// /// The [message] argument cannot be null. - Tooltip({ + const Tooltip({ Key key, @required this.message, this.height: 32.0, @@ -49,14 +49,13 @@ class Tooltip extends StatefulWidget { this.verticalOffset: 24.0, this.preferBelow: true, @required this.child, - }) : super(key: key) { - assert(message != null); - assert(height != null); - assert(padding != null); - assert(verticalOffset != null); - assert(preferBelow != null); - assert(child != null); - } + }) : assert(message != null), + assert(height != null), + assert(padding != null), + assert(verticalOffset != null), + assert(preferBelow != null), + assert(child != null), + super(key: key); /// The text to display in the tooltip. final String message; diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index 65d2bb5a6a..a9a3cb56b5 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -29,7 +29,7 @@ const Duration _kExpand = const Duration(milliseconds: 200); /// * [ListTile] class TwoLevelListItem extends StatelessWidget { /// Creates an item in a two-level list. - TwoLevelListItem({ + const TwoLevelListItem({ Key key, this.leading, @required this.title, @@ -37,9 +37,8 @@ class TwoLevelListItem extends StatelessWidget { this.enabled: true, this.onTap, this.onLongPress - }) : super(key: key) { - assert(title != null); - } + }) : assert(title != null), + super(key: key); /// A widget to display before the title. /// @@ -259,14 +258,13 @@ class TwoLevelList extends StatelessWidget { /// Creates a scrollable list of items that can expand and collapse. /// /// The [type] argument must not be null. - TwoLevelList({ + const TwoLevelList({ Key key, this.children: const [], this.type: MaterialListType.twoLine, this.padding - }) : super(key: key) { - assert(type != null); - } + }) : assert(type != null), + super(key: key); /// The widgets to display in this list. /// diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index cce290897d..6147b9fe3e 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -32,9 +32,8 @@ class TextSelectionPoint { /// Creates a description of a point in a text selection. /// /// The [point] argument must not be null. - TextSelectionPoint(this.point, this.direction) { - assert(point != null); - } + const TextSelectionPoint(this.point, this.direction) + : assert(point != null); /// Screen coordinates of the lower left or lower right corner of the selection. final Offset point; diff --git a/packages/flutter/lib/src/rendering/semantics.dart b/packages/flutter/lib/src/rendering/semantics.dart index e0d8b9831b..72d7fa5acb 100644 --- a/packages/flutter/lib/src/rendering/semantics.dart +++ b/packages/flutter/lib/src/rendering/semantics.dart @@ -60,18 +60,16 @@ class SemanticsData { /// Creates a semantics data object. /// /// The [flags], [actions], [label], and [Rect] arguments must not be null. - SemanticsData({ + const SemanticsData({ @required this.flags, @required this.actions, @required this.label, @required this.rect, this.transform - }) { - assert(flags != null); - assert(actions != null); - assert(label != null); - assert(rect != null); - } + }) : assert(flags != null), + assert(actions != null), + assert(label != null), + assert(rect != null); /// A bit field of [SemanticsFlags] that apply to this node. final int flags; diff --git a/packages/flutter/lib/src/widgets/animated_cross_fade.dart b/packages/flutter/lib/src/widgets/animated_cross_fade.dart index 46f8923a0c..1252665af1 100644 --- a/packages/flutter/lib/src/widgets/animated_cross_fade.dart +++ b/packages/flutter/lib/src/widgets/animated_cross_fade.dart @@ -44,7 +44,7 @@ class AnimatedCrossFade extends StatefulWidget { /// The [duration] of the animation is the same for all components (fade in, /// fade out, and size), and you can pass [Interval]s instead of [Curve]s in /// order to have finer control, e.g., creating an overlap between the fades. - AnimatedCrossFade({ + const AnimatedCrossFade({ Key key, @required this.firstChild, @required this.secondChild, @@ -53,11 +53,10 @@ class AnimatedCrossFade extends StatefulWidget { this.sizeCurve: Curves.linear, @required this.crossFadeState, @required this.duration - }) : super(key: key) { - assert(firstCurve != null); - assert(secondCurve != null); - assert(sizeCurve != null); - } + }) : assert(firstCurve != null), + assert(secondCurve != null), + assert(sizeCurve != null), + super(key: key); /// The child that is visible when [crossFadeState] is [showFirst]. It fades /// out when transitioning from [showFirst] to [showSecond] and vice versa. diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 415b4ce784..828e07cace 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -38,7 +38,7 @@ typedef Future LocaleChangedCallback(Locale locale); class WidgetsApp extends StatefulWidget { /// Creates a widget that wraps a number of widgets that are commonly /// required for an application. - WidgetsApp({ + const WidgetsApp({ Key key, @required this.onGenerateRoute, this.title, @@ -51,13 +51,12 @@ class WidgetsApp extends StatefulWidget { this.checkerboardRasterCacheImages: false, this.showSemanticsDebugger: false, this.debugShowCheckedModeBanner: true - }) : super(key: key) { - assert(color != null); - assert(onGenerateRoute != null); - assert(showPerformanceOverlay != null); - assert(checkerboardRasterCacheImages != null); - assert(showSemanticsDebugger != null); - } + }) : assert(color != null), + assert(onGenerateRoute != null), + assert(showPerformanceOverlay != null), + assert(checkerboardRasterCacheImages != null), + assert(showSemanticsDebugger != null), + super(key: key); /// A one-line description of this app for use in the window manager. final String title; diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 3e3121a01b..5daf39eacd 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -187,19 +187,18 @@ enum ConnectionState { class AsyncSnapshot { /// Creates an [AsyncSnapshot] with the specified [connectionState], /// and optionally either [data] or [error] (but not both). - AsyncSnapshot._(this.connectionState, this.data, this.error) { - assert(connectionState != null); - assert(data == null || error == null); - } + const AsyncSnapshot._(this.connectionState, this.data, this.error) + : assert(connectionState != null), + assert(!(data != null && error != null)); /// Creates an [AsyncSnapshot] in [ConnectionState.none] with null data and error. - AsyncSnapshot.nothing() : this._(ConnectionState.none, null, null); + const AsyncSnapshot.nothing() : this._(ConnectionState.none, null, null); /// Creates an [AsyncSnapshot] in the specified [state] and with the specified [data]. - AsyncSnapshot.withData(ConnectionState state, T data) : this._(state, data, null); + AsyncSnapshot.withData(ConnectionState state, T data) : this._(state, data, null); // not const because https://github.com/dart-lang/sdk/issues/29432 /// Creates an [AsyncSnapshot] in the specified [state] and with the specified [error]. - AsyncSnapshot.withError(ConnectionState state, Object error) : this._(state, null, error); + const AsyncSnapshot.withError(ConnectionState state, Object error) : this._(state, null, error); /// Current state of connection to the asynchronous computation. final ConnectionState connectionState; @@ -309,19 +308,18 @@ class StreamBuilder extends StreamBuilderBase> { /// Creates a new [StreamBuilder] that builds itself based on the latest /// snapshot of interaction with the specified [stream] and whose build /// strategy is given by [builder]. - StreamBuilder({ + const StreamBuilder({ Key key, Stream stream, @required this.builder - }) : super(key: key, stream: stream) { - assert(builder != null); - } + }) : assert(builder != null), + super(key: key, stream: stream); /// The build strategy currently used by this builder. Cannot be null. final AsyncWidgetBuilder builder; @override - AsyncSnapshot initial() => new AsyncSnapshot.nothing(); + AsyncSnapshot initial() => new AsyncSnapshot.nothing(); // ignore: prefer_const_constructors @override AsyncSnapshot afterConnected(AsyncSnapshot current) => current.inState(ConnectionState.waiting); @@ -387,13 +385,12 @@ class FutureBuilder extends StatefulWidget { /// interaction with a [Future]. /// /// The [builder] must not be null. - FutureBuilder({ + const FutureBuilder({ Key key, this.future, @required this.builder - }) : super(key: key) { - assert(builder != null); - } + }) : assert(builder != null), + super(key: key); /// The asynchronous computation to which this builder is currently connected, /// possibly null. @@ -412,7 +409,7 @@ class _FutureBuilderState extends State> { /// calling setState from stale callbacks, e.g. after disposal of this state, /// or after widget reconfiguration to a new Future. Object _activeCallbackIdentity; - AsyncSnapshot _snapshot = new AsyncSnapshot.nothing(); + AsyncSnapshot _snapshot = new AsyncSnapshot.nothing(); // ignore: prefer_const_constructors @override void initState() { diff --git a/packages/flutter/lib/src/widgets/dismissible.dart b/packages/flutter/lib/src/widgets/dismissible.dart index ca8a3166b2..85cfef6cad 100644 --- a/packages/flutter/lib/src/widgets/dismissible.dart +++ b/packages/flutter/lib/src/widgets/dismissible.dart @@ -71,7 +71,7 @@ class Dismissible extends StatefulWidget { /// which means the item after the dismissed item would be synced with the /// state of the dismissed item. Using keys causes the widgets to sync /// according to their keys and avoids this pitfall. - Dismissible({ + const Dismissible({ @required Key key, @required this.child, this.background, @@ -81,10 +81,9 @@ class Dismissible extends StatefulWidget { this.direction: DismissDirection.horizontal, this.resizeDuration: const Duration(milliseconds: 300), this.dismissThresholds: const {}, - }) : super(key: key) { - assert(key != null); - assert(secondaryBackground != null ? background != null : true); - } + }) : assert(key != null), + assert(secondaryBackground != null ? background != null : true), + super(key: key); /// The widget below this widget in the tree. final Widget child; diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index bfdc2b99b2..c2143f76ac 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -117,7 +117,7 @@ class EditableText extends StatefulWidget { /// /// The [controller], [focusNode], [style], and [cursorColor] arguments must /// not be null. - EditableText({ + const EditableText({ Key key, @required this.controller, @required this.focusNode, @@ -133,15 +133,14 @@ class EditableText extends StatefulWidget { this.keyboardType, this.onChanged, this.onSubmitted, - }) : super(key: key) { - assert(controller != null); - assert(focusNode != null); - assert(obscureText != null); - assert(style != null); - assert(cursorColor != null); - assert(maxLines != null); - assert(autofocus != null); - } + }) : assert(controller != null), + assert(focusNode != null), + assert(obscureText != null), + assert(style != null), + assert(cursorColor != null), + assert(maxLines != null), + assert(autofocus != null), + super(key: key); /// Controls the text being edited. final TextEditingController controller; diff --git a/packages/flutter/lib/src/widgets/focus_scope.dart b/packages/flutter/lib/src/widgets/focus_scope.dart index f5c9bbb6b8..5e37a27a8d 100644 --- a/packages/flutter/lib/src/widgets/focus_scope.dart +++ b/packages/flutter/lib/src/widgets/focus_scope.dart @@ -10,13 +10,12 @@ import 'focus_manager.dart'; import 'framework.dart'; class _FocusScopeMarker extends InheritedWidget { - _FocusScopeMarker({ + const _FocusScopeMarker({ Key key, @required this.node, Widget child, - }) : super(key: key, child: child) { - assert(node != null); - } + }) : assert(node != null), + super(key: key, child: child); final FocusScopeNode node; @@ -53,15 +52,14 @@ class FocusScope extends StatefulWidget { /// Creates a scope in which widgets can receive focus. /// /// The [node] argument must not be null. - FocusScope({ + const FocusScope({ Key key, @required this.node, this.autofocus: false, this.child, - }) : super(key: key) { - assert(node != null); - assert(autofocus != null); - } + }) : assert(node != null), + assert(autofocus != null), + super(key: key); /// Controls whether this scope is currently active. final FocusScopeNode node; diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index b0c18337ba..4f42b4ad4e 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -21,14 +21,13 @@ class Form extends StatefulWidget { /// Creates a container for form fields. /// /// The [child] argument must not be null. - Form({ + const Form({ Key key, @required this.child, this.autovalidate: false, this.onWillPop, - }) : super(key: key) { - assert(child != null); - } + }) : assert(child != null), + super(key: key); /// Returns the closest [FormState] which encloses the given context. /// @@ -194,16 +193,15 @@ class FormField extends StatefulWidget { /// Creates a single form field. /// /// The [builder] argument must not be null. - FormField({ + const FormField({ Key key, @required this.builder, this.onSaved, this.validator, this.initialValue, this.autovalidate: false, - }) : super(key: key) { - assert(builder != null); - } + }) : assert(builder != null), + super(key: key); /// An optional method to call with the final value when the form is saved via /// Form.save(). diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 6193216db8..fc820bd79c 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -325,16 +325,15 @@ class RawGestureDetector extends StatefulWidget { /// /// By default, gesture detectors contribute semantic information to the tree /// that is used by assistive technology. - RawGestureDetector({ + const RawGestureDetector({ Key key, this.child, this.gestures: const {}, this.behavior, this.excludeFromSemantics: false - }) : super(key: key) { - assert(gestures != null); - assert(excludeFromSemantics != null); - } + }) : assert(gestures != null), + assert(excludeFromSemantics != null), + super(key: key); /// The widget below this widget in the tree. final Widget child; diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index ba189d5128..3f3895ec49 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -77,14 +77,13 @@ class Hero extends StatefulWidget { /// Create a hero. /// /// The [tag] and [child] parameters must not be null. - Hero({ + const Hero({ Key key, @required this.tag, @required this.child, - }) : super(key: key) { - assert(tag != null); - assert(child != null); - } + }) : assert(tag != null), + assert(child != null), + super(key: key); /// The identifier for this particular hero. If the tag of this hero matches /// the tag of a hero on a [PageRoute] that we're navigating to or from, then diff --git a/packages/flutter/lib/src/widgets/image.dart b/packages/flutter/lib/src/widgets/image.dart index a16c138b79..b0a0b136d3 100644 --- a/packages/flutter/lib/src/widgets/image.dart +++ b/packages/flutter/lib/src/widgets/image.dart @@ -63,7 +63,7 @@ class Image extends StatefulWidget { /// [new Image.network] and [new Image.asset] respectively. /// /// The [image] and [repeat] arguments must not be null. - Image({ + const Image({ Key key, @required this.image, this.width, @@ -75,9 +75,8 @@ class Image extends StatefulWidget { this.repeat: ImageRepeat.noRepeat, this.centerSlice, this.gaplessPlayback: false - }) : super(key: key) { - assert(image != null); - } + }) : assert(image != null), + super(key: key); /// Creates a widget that displays an [ImageStream] obtained from the network. /// diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 785a795adc..d6f80d8d50 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -88,14 +88,13 @@ abstract class ImplicitlyAnimatedWidget extends StatefulWidget { /// Initializes fields for subclasses. /// /// The [curve] and [duration] arguments must not be null. - ImplicitlyAnimatedWidget({ + const ImplicitlyAnimatedWidget({ Key key, this.curve: Curves.linear, @required this.duration - }) : super(key: key) { - assert(curve != null); - assert(duration != null); - } + }) : assert(curve != null), + assert(duration != null), + super(key: key); /// The curve to apply when animating the parameters of this container. final Curve curve; @@ -386,7 +385,7 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget { /// the three must be null. /// /// The [curve] and [duration] arguments must not be null. - AnimatedPositioned({ + const AnimatedPositioned({ Key key, @required this.child, this.left, @@ -397,10 +396,9 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget { this.height, Curve curve: Curves.linear, @required Duration duration, - }) : super(key: key, curve: curve, duration: duration) { - assert(left == null || right == null || width == null); - assert(top == null || bottom == null || height == null); - } + }) : assert(left == null || right == null || width == null), + assert(top == null || bottom == null || height == null), + super(key: key, curve: curve, duration: duration); /// Creates a widget that animates the rectangle it occupies implicitly. /// @@ -526,15 +524,14 @@ class AnimatedOpacity extends ImplicitlyAnimatedWidget { /// /// The [opacity] argument must not be null and must be between 0.0 and 1.0, /// inclusive. The [curve] and [duration] arguments must not be null. - AnimatedOpacity({ + const AnimatedOpacity({ Key key, this.child, @required this.opacity, Curve curve: Curves.linear, @required Duration duration, - }) : super(key: key, curve: curve, duration: duration) { - assert(opacity != null && opacity >= 0.0 && opacity <= 1.0); - } + }) : assert(opacity != null && opacity >= 0.0 && opacity <= 1.0), + super(key: key, curve: curve, duration: duration); /// The widget below this widget in the tree. final Widget child; @@ -583,16 +580,15 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget { /// Creates a widget that animates the default text style implicitly. /// /// The [child], [style], [curve], and [duration] arguments must not be null. - AnimatedDefaultTextStyle({ + const AnimatedDefaultTextStyle({ Key key, @required this.child, @required this.style, Curve curve: Curves.linear, @required Duration duration, - }) : super(key: key, curve: curve, duration: duration) { - assert(style != null); - assert(child != null); - } + }) : assert(style != null), + assert(child != null), + super(key: key, curve: curve, duration: duration); /// The widget below this widget in the tree. final Widget child; diff --git a/packages/flutter/lib/src/widgets/layout_builder.dart b/packages/flutter/lib/src/widgets/layout_builder.dart index 6e476b3bc3..dc6e59cac9 100644 --- a/packages/flutter/lib/src/widgets/layout_builder.dart +++ b/packages/flutter/lib/src/widgets/layout_builder.dart @@ -32,12 +32,11 @@ class LayoutBuilder extends RenderObjectWidget { /// Creates a widget that defers its building until layout. /// /// The [builder] argument must not be null. - LayoutBuilder({ + const LayoutBuilder({ Key key, @required this.builder - }) : super(key: key) { - assert(builder != null); - } + }) : assert(builder != null), + super(key: key); /// Called at layout time to construct the widget tree. The builder must not /// return null. diff --git a/packages/flutter/lib/src/widgets/locale_query.dart b/packages/flutter/lib/src/widgets/locale_query.dart index 9c0359fc65..bc156bd0e2 100644 --- a/packages/flutter/lib/src/widgets/locale_query.dart +++ b/packages/flutter/lib/src/widgets/locale_query.dart @@ -12,13 +12,12 @@ class LocaleQueryData { } // TODO(ianh): We need a better type here. This doesn' /// Establishes a subtree in which locale queries resolve to the given data. class LocaleQuery extends InheritedWidget { /// Creates a widget that provides [LocaleQueryData] to its descendants. - LocaleQuery({ + const LocaleQuery({ Key key, @required this.data, @required Widget child - }) : super(key: key, child: child) { - assert(child != null); - } + }) : assert(child != null), + super(key: key, child: child); /// The locale data for this subtree. final LocaleQueryData data; diff --git a/packages/flutter/lib/src/widgets/media_query.dart b/packages/flutter/lib/src/widgets/media_query.dart index df53bccf00..2d20dfaf12 100644 --- a/packages/flutter/lib/src/widgets/media_query.dart +++ b/packages/flutter/lib/src/widgets/media_query.dart @@ -121,14 +121,13 @@ class MediaQuery extends InheritedWidget { /// Creates a widget that provides [MediaQueryData] to its descendants. /// /// The [data] and [child] arguments must not be null. - MediaQuery({ + const MediaQuery({ Key key, @required this.data, @required Widget child, - }) : super(key: key, child: child) { - assert(child != null); - assert(data != null); - } + }) : assert(child != null), + assert(data != null), + super(key: key, child: child); /// Contains information about the current media. /// diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index ab5430c2be..8fefac3ceb 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -475,15 +475,14 @@ class Navigator extends StatefulWidget { /// Creates a widget that maintains a stack-based history of child widgets. /// /// The [onGenerateRoute] argument must not be null. - Navigator({ + const Navigator({ Key key, this.initialRoute, @required this.onGenerateRoute, this.onUnknownRoute, this.observers: const [] - }) : super(key: key) { - assert(onGenerateRoute != null); - } + }) : assert(onGenerateRoute != null), + super(key: key); /// The name of the first route to show. final String initialRoute; diff --git a/packages/flutter/lib/src/widgets/orientation_builder.dart b/packages/flutter/lib/src/widgets/orientation_builder.dart index c4dd51cd25..a5b8eac158 100644 --- a/packages/flutter/lib/src/widgets/orientation_builder.dart +++ b/packages/flutter/lib/src/widgets/orientation_builder.dart @@ -27,12 +27,11 @@ class OrientationBuilder extends StatelessWidget { /// Creates an orientation builder. /// /// The [builder] argument must not be null. - OrientationBuilder({ + const OrientationBuilder({ Key key, @required this.builder, - }) : super(key: key) { - assert(builder != null); - } + }) : assert(builder != null), + super(key: key); /// Builds the widgets below this widget given this widget's orientation. final OrientationWidgetBuilder builder; diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index ab2d763856..e2140b5c39 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -201,12 +201,11 @@ class Overlay extends StatefulWidget { /// Rather than creating an overlay, consider using the overlay that has /// already been created by the [WidgetsApp] or the [MaterialApp] for this /// application. - Overlay({ + const Overlay({ Key key, this.initialEntries: const [] - }) : super(key: key) { - assert(initialEntries != null); - } + }) : assert(initialEntries != null), + super(key: key); /// The entries to include in the overlay initially. /// diff --git a/packages/flutter/lib/src/widgets/overscroll_indicator.dart b/packages/flutter/lib/src/widgets/overscroll_indicator.dart index ab12040909..9dd4e7619a 100644 --- a/packages/flutter/lib/src/widgets/overscroll_indicator.dart +++ b/packages/flutter/lib/src/widgets/overscroll_indicator.dart @@ -33,19 +33,18 @@ class GlowingOverscrollIndicator extends StatefulWidget { /// /// The [showLeading], [showTrailing], [axisDirection], and [color] arguments /// must not be null. - GlowingOverscrollIndicator({ + const GlowingOverscrollIndicator({ Key key, this.showLeading: true, this.showTrailing: true, @required this.axisDirection, @required this.color, this.child, - }) : super(key: key) { - assert(showLeading != null); - assert(showTrailing != null); - assert(axisDirection != null); - assert(color != null); - } + }) : assert(showLeading != null), + assert(showTrailing != null), + assert(axisDirection != null), + assert(color != null), + super(key: key); /// Whether to show the overscroll glow on the side with negative scroll /// offsets. diff --git a/packages/flutter/lib/src/widgets/page_storage.dart b/packages/flutter/lib/src/widgets/page_storage.dart index 2b0a44d878..7d71ac87db 100644 --- a/packages/flutter/lib/src/widgets/page_storage.dart +++ b/packages/flutter/lib/src/widgets/page_storage.dart @@ -104,13 +104,12 @@ class PageStorage extends StatelessWidget { /// Creates a widget that provides a storage bucket for its descendants. /// /// The [bucket] argument must not be null. - PageStorage({ + const PageStorage({ Key key, @required this.bucket, @required this.child - }) : super(key: key) { - assert(bucket != null); - } + }) : assert(bucket != null), + super(key: key); /// The widget below this widget in the tree. final Widget child; diff --git a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart index 855f902808..42659b015b 100644 --- a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart +++ b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart @@ -8,13 +8,12 @@ import 'framework.dart'; import 'scroll_controller.dart'; class PrimaryScrollController extends InheritedWidget { - PrimaryScrollController({ + const PrimaryScrollController({ Key key, @required this.controller, @required Widget child - }) : super(key: key, child: child) { - assert(controller != null); - } + }) : assert(controller != null), + super(key: key, child: child); const PrimaryScrollController.none({ Key key, diff --git a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart index 8a0d7c3e62..bdad69f8f2 100644 --- a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart +++ b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart @@ -28,15 +28,14 @@ class RawKeyboardListener extends StatefulWidget { /// /// For text entry, consider using a [EditableText], which integrates with /// on-screen keyboards and input method editors (IMEs). - RawKeyboardListener({ + const RawKeyboardListener({ Key key, @required this.focusNode, @required this.onKey, @required this.child, - }) : super(key: key) { - assert(focusNode != null); - assert(child != null); - } + }) : assert(focusNode != null), + assert(child != null), + super(key: key); /// Controls whether this widget has keyboard focus. final FocusNode focusNode; diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 14d6f4df20..3922b02e2d 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -354,18 +354,17 @@ abstract class LocalHistoryRoute extends Route { } class _ModalScopeStatus extends InheritedWidget { - _ModalScopeStatus({ + const _ModalScopeStatus({ Key key, @required this.isCurrent, @required this.canPop, @required this.route, @required Widget child - }) : super(key: key, child: child) { - assert(isCurrent != null); - assert(canPop != null); - assert(route != null); - assert(child != null); - } + }) : assert(isCurrent != null), + assert(canPop != null), + assert(route != null), + assert(child != null), + super(key: key, child: child); final bool isCurrent; final bool canPop; diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 357653e6de..89f2263ee3 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -25,16 +25,15 @@ export 'package:flutter/physics.dart' show Tolerance; typedef Widget ViewportBuilder(BuildContext context, ViewportOffset position); class Scrollable extends StatefulWidget { - Scrollable({ + const Scrollable({ Key key, this.axisDirection: AxisDirection.down, this.controller, this.physics, @required this.viewportBuilder, - }) : super (key: key) { - assert(axisDirection != null); - assert(viewportBuilder != null); - } + }) : assert(axisDirection != null), + assert(viewportBuilder != null), + super (key: key); final AxisDirection axisDirection; @@ -100,15 +99,14 @@ class Scrollable extends StatefulWidget { // Enable Scrollable.of() to work as if ScrollableState was an inherited widget. // ScrollableState.build() always rebuilds its _ScrollableScope. class _ScrollableScope extends InheritedWidget { - _ScrollableScope({ + const _ScrollableScope({ Key key, @required this.scrollable, @required this.position, @required Widget child - }) : super(key: key, child: child) { - assert(scrollable != null); - assert(child != null); - } + }) : assert(scrollable != null), + assert(child != null), + super(key: key, child: child); final ScrollableState scrollable; final ScrollPosition position; diff --git a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart index 0be8825f94..bef55ff859 100644 --- a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart @@ -146,14 +146,13 @@ class SingleChildScrollView extends StatelessWidget { } class _SingleChildViewport extends SingleChildRenderObjectWidget { - _SingleChildViewport({ + const _SingleChildViewport({ Key key, this.axisDirection: AxisDirection.down, this.offset, Widget child, - }) : super(key: key, child: child) { - assert(axisDirection != null); - } + }) : assert(axisDirection != null), + super(key: key, child: child); final AxisDirection axisDirection; final ViewportOffset offset; diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index 40b7f31c4e..46668f0f86 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -426,14 +426,13 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget { /// extent in the main axis. class SliverFillViewport extends SliverMultiBoxAdaptorWidget { /// Creates a sliver whose box children that each fill the viewport. - SliverFillViewport({ + const SliverFillViewport({ Key key, @required SliverChildDelegate delegate, this.viewportFraction: 1.0, - }) : super(key: key, delegate: delegate) { - assert(viewportFraction != null); - assert(viewportFraction > 0.0); - } + }) : assert(viewportFraction != null), + assert(viewportFraction > 0.0), + super(key: key, delegate: delegate); /// The fraction of the viewport that each child should fill in the main axis. /// diff --git a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart index d466be142b..8e90bedffc 100644 --- a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart @@ -29,16 +29,15 @@ abstract class SliverPersistentHeaderDelegate { } class SliverPersistentHeader extends StatelessWidget { - SliverPersistentHeader({ + const SliverPersistentHeader({ Key key, @required this.delegate, this.pinned: false, this.floating: false, - }) : super(key: key) { - assert(delegate != null); - assert(pinned != null); - assert(floating != null); - } + }) : assert(delegate != null), + assert(pinned != null), + assert(floating != null), + super(key: key); final SliverPersistentHeaderDelegate delegate; diff --git a/packages/flutter/lib/src/widgets/ticker_provider.dart b/packages/flutter/lib/src/widgets/ticker_provider.dart index 277bb92e76..4850c37fe1 100644 --- a/packages/flutter/lib/src/widgets/ticker_provider.dart +++ b/packages/flutter/lib/src/widgets/ticker_provider.dart @@ -19,13 +19,12 @@ class TickerMode extends InheritedWidget { /// Creates a widget that enables or disables tickers. /// /// The [enabled] argument must not be null. - TickerMode({ + const TickerMode({ Key key, @required this.enabled, Widget child - }) : super(key: key, child: child) { - assert(enabled != null); - } + }) : assert(enabled != null), + super(key: key, child: child); /// The current ticker mode of this subtree. /// diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index e9e0d30f09..3c59e294aa 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -219,15 +219,14 @@ class SizeTransition extends AnimatedWidget { /// The [sizeFactor] argument must not be null. The [axis] argument defaults /// to [Axis.vertical]. The [axisAlignment] defaults to 0.5, which centers the /// child along the main axis during the transition. - SizeTransition({ + const SizeTransition({ Key key, this.axis: Axis.vertical, @required Animation sizeFactor, this.axisAlignment: 0.5, this.child, - }) : super(key: key, listenable: sizeFactor) { - assert(axis != null); - } + }) : assert(axis != null), + super(key: key, listenable: sizeFactor); /// [Axis.horizontal] if [sizeFactor] modifies the width, otherwise [Axis.vertical]. final Axis axis; @@ -465,14 +464,13 @@ class AnimatedBuilder extends AnimatedWidget { /// Creates an animated builder. /// /// The [animation] and [builder] arguments must not be null. - AnimatedBuilder({ + const AnimatedBuilder({ Key key, @required Listenable animation, @required this.builder, this.child, - }) : super(key: key, listenable: animation) { - assert(builder != null); - } + }) : assert(builder != null), + super(key: key, listenable: animation); /// Called every time the animation changes value. final TransitionBuilder builder; diff --git a/packages/flutter/lib/src/widgets/will_pop_scope.dart b/packages/flutter/lib/src/widgets/will_pop_scope.dart index 7bb4620db8..45b3e66e8b 100644 --- a/packages/flutter/lib/src/widgets/will_pop_scope.dart +++ b/packages/flutter/lib/src/widgets/will_pop_scope.dart @@ -19,13 +19,12 @@ class WillPopScope extends StatefulWidget { /// dismiss the enclosing [ModalRoute]. /// /// The [child] argument must not be null. - WillPopScope({ + const WillPopScope({ Key key, @required this.child, @required this.onWillPop, - }) : super(key: key) { - assert(child != null); - } + }) : assert(child != null), + super(key: key); /// The widget below this widget in the tree. final Widget child; diff --git a/packages/flutter/test/cupertino/activity_indicator_test.dart b/packages/flutter/test/cupertino/activity_indicator_test.dart index 1a03fbb0e5..5f84af36a2 100644 --- a/packages/flutter/test/cupertino/activity_indicator_test.dart +++ b/packages/flutter/test/cupertino/activity_indicator_test.dart @@ -9,18 +9,18 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Activity indicator animate property works', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new CupertinoActivityIndicator())); + await tester.pumpWidget(const Center(child: const CupertinoActivityIndicator())); expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); - await tester.pumpWidget(new Center(child: new CupertinoActivityIndicator(animating: false))); + await tester.pumpWidget(const Center(child: const CupertinoActivityIndicator(animating: false))); expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); await tester.pumpWidget(new Container()); - await tester.pumpWidget(new Center(child: new CupertinoActivityIndicator(animating: false))); + await tester.pumpWidget(const Center(child: const CupertinoActivityIndicator(animating: false))); expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); - await tester.pumpWidget(new Center(child: new CupertinoActivityIndicator())); + await tester.pumpWidget(const Center(child: const CupertinoActivityIndicator())); expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); }); } diff --git a/packages/flutter/test/cupertino/button_test.dart b/packages/flutter/test/cupertino/button_test.dart index b7e966bb91..5e4c02604a 100644 --- a/packages/flutter/test/cupertino/button_test.dart +++ b/packages/flutter/test/cupertino/button_test.dart @@ -15,7 +15,7 @@ const TextStyle testStyle = const TextStyle( void main() { testWidgets('Default layout minimum size', (WidgetTester tester) async { await tester.pumpWidget( - new Center(child: new CupertinoButton( + const Center(child: const CupertinoButton( child: const Text('X', style: testStyle), onPressed: null, )) @@ -47,7 +47,7 @@ void main() { testWidgets('Size grows with text', (WidgetTester tester) async { await tester.pumpWidget( - new Center(child: new CupertinoButton( + const Center(child: const CupertinoButton( child: const Text('XXXX', style: testStyle), onPressed: null, )) @@ -61,7 +61,7 @@ void main() { }); testWidgets('Button with background is wider', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new CupertinoButton( + await tester.pumpWidget(const Center(child: const CupertinoButton( child: const Text('X', style: testStyle), onPressed: null, color: const Color(0xFFFFFFFF), @@ -75,7 +75,7 @@ void main() { }); testWidgets('Custom padding', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new CupertinoButton( + await tester.pumpWidget(const Center(child: const CupertinoButton( child: const Text(' ', style: testStyle), onPressed: null, padding: const EdgeInsets.all(100.0), @@ -116,7 +116,7 @@ void main() { }); testWidgets('Disabled button doesn\'t animate', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new CupertinoButton( + await tester.pumpWidget(const Center(child: const CupertinoButton( child: const Text('Tap me'), onPressed: null, ))); diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index 82266c3f2d..2f7b0fc395 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -23,7 +23,7 @@ void main() { title: const Text('The title'), content: const Text('The content'), actions: [ - new CupertinoDialogAction( + const CupertinoDialogAction( child: const Text('Cancel'), ), new CupertinoDialogAction( @@ -64,7 +64,7 @@ void main() { }); testWidgets('Dialog action styles', (WidgetTester tester) async { - await tester.pumpWidget(new CupertinoDialogAction( + await tester.pumpWidget(const CupertinoDialogAction( isDestructive: true, child: const Text('Ok'), )); diff --git a/packages/flutter/test/material/about_test.dart b/packages/flutter/test/material/about_test.dart index e955a8bbe4..940a1ef6ac 100644 --- a/packages/flutter/test/material/about_test.dart +++ b/packages/flutter/test/material/about_test.dart @@ -67,7 +67,7 @@ void main() { testWidgets('About box logic defaults to executable name for app name', (WidgetTester tester) async { await tester.pumpWidget( - new Material(child: const AboutListTile()), + const Material(child: const AboutListTile()), ); expect(find.text('About flutter_tester'), findsOneWidget); }); diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart index 489fbadc8f..f1e8c1a02c 100644 --- a/packages/flutter/test/material/back_button_test.dart +++ b/packages/flutter/test/material/back_button_test.dart @@ -9,10 +9,10 @@ void main() { testWidgets('BackButton control test', (WidgetTester tester) async { await tester.pumpWidget( new MaterialApp( - home: new Material(child: const Text('Home')), + home: const Material(child: const Text('Home')), routes: { '/next': (BuildContext context) { - return new Material( + return const Material( child: const Center( child: const BackButton(), ) diff --git a/packages/flutter/test/material/debug_test.dart b/packages/flutter/test/material/debug_test.dart index 76f14fa591..46da6b01b3 100644 --- a/packages/flutter/test/material/debug_test.dart +++ b/packages/flutter/test/material/debug_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('debugCheckHasMaterial control test', (WidgetTester tester) async { - await tester.pumpWidget(new FlatButton( + await tester.pumpWidget(const FlatButton( onPressed: null, child: const Text('Go'), )); diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index b50cc36cd9..e4a3497d5b 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -100,7 +100,7 @@ void main() { testWidgets('Simple dialog control test', (WidgetTester tester) async { await tester.pumpWidget( new MaterialApp( - home: new Material( + home: const Material( child: const Center( child: const RaisedButton( onPressed: null, @@ -141,7 +141,7 @@ void main() { testWidgets('Barrier dismissible', (WidgetTester tester) async { await tester.pumpWidget( new MaterialApp( - home: new Material( + home: const Material( child: const Center( child: const RaisedButton( onPressed: null, diff --git a/packages/flutter/test/material/divider_test.dart b/packages/flutter/test/material/divider_test.dart index 7e7a163aac..72e52bacf7 100644 --- a/packages/flutter/test/material/divider_test.dart +++ b/packages/flutter/test/material/divider_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Divider control test', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new Divider())); + await tester.pumpWidget(const Center(child: const Divider())); final RenderBox box = tester.firstRenderObject(find.byType(Divider)); expect(box.size.height, 15.0); }); diff --git a/packages/flutter/test/material/drawer_test.dart b/packages/flutter/test/material/drawer_test.dart index d73593b4cc..4cfa68976f 100644 --- a/packages/flutter/test/material/drawer_test.dart +++ b/packages/flutter/test/material/drawer_test.dart @@ -20,7 +20,7 @@ void main() { child: const Text('header') ) ), - new ListTile( + const ListTile( leading: const Icon(Icons.archive), title: const Text('Archive') ) diff --git a/packages/flutter/test/material/expand_icon_test.dart b/packages/flutter/test/material/expand_icon_test.dart index f64d47f5cd..e4a02b7da9 100644 --- a/packages/flutter/test/material/expand_icon_test.dart +++ b/packages/flutter/test/material/expand_icon_test.dart @@ -31,9 +31,9 @@ void main() { testWidgets('ExpandIcon disabled', (WidgetTester tester) async { await tester.pumpWidget( - new Material( - child: new Center( - child: new ExpandIcon( + const Material( + child: const Center( + child: const ExpandIcon( onPressed: null ) ) diff --git a/packages/flutter/test/material/grid_title_test.dart b/packages/flutter/test/material/grid_title_test.dart index 5592d7a87a..7a36db30f5 100644 --- a/packages/flutter/test/material/grid_title_test.dart +++ b/packages/flutter/test/material/grid_title_test.dart @@ -36,7 +36,7 @@ void main() { expect(tester.getBottomLeft(find.byKey(headerKey)).dy, lessThan(tester.getTopLeft(find.byKey(footerKey)).dy)); - await tester.pumpWidget(new GridTile(child: const Text('Simple'))); + await tester.pumpWidget(const GridTile(child: const Text('Simple'))); expect(find.text('Simple'), findsOneWidget); }); diff --git a/packages/flutter/test/material/icon_test.dart b/packages/flutter/test/material/icon_test.dart index 687c60d9eb..9dcd47bb9a 100644 --- a/packages/flutter/test/material/icon_test.dart +++ b/packages/flutter/test/material/icon_test.dart @@ -35,8 +35,8 @@ void main() { testWidgets('Icon sizing - sized theme', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new IconTheme( + const Center( + child: const IconTheme( data: const IconThemeData(size: 36.0), child: const Icon(null), ), @@ -49,8 +49,8 @@ void main() { testWidgets('Icon sizing - sized theme, explicit size', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new IconTheme( + const Center( + child: const IconTheme( data: const IconThemeData(size: 36.0), child: const Icon( null, @@ -66,8 +66,8 @@ void main() { testWidgets('Icon sizing - sizeless theme, default size', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new IconTheme( + const Center( + child: const IconTheme( data: const IconThemeData(), child: const Icon(null), ), diff --git a/packages/flutter/test/material/image_icon_test.dart b/packages/flutter/test/material/image_icon_test.dart index bf14f054ff..56b719dc63 100644 --- a/packages/flutter/test/material/image_icon_test.dart +++ b/packages/flutter/test/material/image_icon_test.dart @@ -27,8 +27,8 @@ void main() { testWidgets('Icon opacity', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new IconTheme( + const Center( + child: const IconTheme( data: const IconThemeData(opacity: 0.5), child: const ImageIcon(_kImage), ), @@ -56,8 +56,8 @@ void main() { testWidgets('ImageIcon sizing - sized theme', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new IconTheme( + const Center( + child: const IconTheme( data: const IconThemeData(size: 36.0), child: const ImageIcon(null) ) @@ -70,8 +70,8 @@ void main() { testWidgets('ImageIcon sizing - sized theme, explicit size', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new IconTheme( + const Center( + child: const IconTheme( data: const IconThemeData(size: 36.0), child: const ImageIcon( null, @@ -87,8 +87,8 @@ void main() { testWidgets('ImageIcon sizing - sizeless theme, default size', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new IconTheme( + const Center( + child: const IconTheme( data: const IconThemeData(), child: const ImageIcon(null) ) diff --git a/packages/flutter/test/material/mergeable_material_test.dart b/packages/flutter/test/material/mergeable_material_test.dart index a9aa4d3e83..857c957e70 100644 --- a/packages/flutter/test/material/mergeable_material_test.dart +++ b/packages/flutter/test/material/mergeable_material_test.dart @@ -81,7 +81,7 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, @@ -102,7 +102,7 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, @@ -125,14 +125,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -155,14 +155,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, @@ -190,7 +190,7 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, @@ -219,17 +219,17 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -253,14 +253,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -292,14 +292,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -322,17 +322,17 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -364,14 +364,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -394,17 +394,17 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -434,14 +434,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -471,17 +471,17 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, @@ -513,14 +513,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -543,21 +543,21 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -581,21 +581,21 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -618,14 +618,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -650,14 +650,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -680,27 +680,27 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('y') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -734,27 +734,27 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('y') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -779,14 +779,14 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -818,17 +818,17 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -852,27 +852,27 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('y') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('z') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -906,27 +906,27 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('y') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -951,17 +951,17 @@ void main() { body: new SingleChildScrollView( child: new MergeableMaterial( children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('z') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, @@ -1006,28 +1006,28 @@ void main() { child: new MergeableMaterial( hasDividers: true, children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('D'), child: const SizedBox( width: 100.0, @@ -1054,31 +1054,31 @@ void main() { child: new MergeableMaterial( hasDividers: true, children: [ - new MaterialSlice( + const MaterialSlice( key: const ValueKey('A'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('B'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialGap( + const MaterialGap( key: const ValueKey('x') ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('C'), child: const SizedBox( width: 100.0, height: 100.0 ) ), - new MaterialSlice( + const MaterialSlice( key: const ValueKey('D'), child: const SizedBox( width: 100.0, diff --git a/packages/flutter/test/material/page_test.dart b/packages/flutter/test/material/page_test.dart index c9184c7029..b622c39dc2 100644 --- a/packages/flutter/test/material/page_test.dart +++ b/packages/flutter/test/material/page_test.dart @@ -11,10 +11,10 @@ void main() { await tester.pumpWidget( new MaterialApp( theme: new ThemeData(platform: TargetPlatform.android), - home: new Material(child: const Text('Page 1')), + home: const Material(child: const Text('Page 1')), routes: { '/next': (BuildContext context) { - return new Material(child: const Text('Page 2')); + return const Material(child: const Text('Page 2')); }, }, ) @@ -62,7 +62,7 @@ void main() { await tester.pumpWidget( new MaterialApp( theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Material(child: const Text('Page 1')), + home: const Material(child: const Text('Page 1')), routes: { '/next': (BuildContext context) { return new Material( @@ -141,7 +141,7 @@ void main() { await tester.pumpWidget( new MaterialApp( theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Material(child: const Text('Page 1')), + home: const Material(child: const Text('Page 1')), ) ); @@ -149,7 +149,7 @@ void main() { tester.state(find.byType(Navigator)).push(new MaterialPageRoute( builder: (BuildContext context) { - return new Material(child: const Text('Page 2')); + return const Material(child: const Text('Page 2')); }, fullscreenDialog: true, )); diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 92f4e235f7..a6651c0884 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -137,7 +137,7 @@ void main() { ), body: new CustomScrollView( slivers: [ - new SliverAppBar( + const SliverAppBar( pinned: true, expandedHeight: appBarHeight, title: const Text('Title'), @@ -184,7 +184,7 @@ void main() { body: new CustomScrollView( primary: true, slivers: [ - new SliverAppBar( + const SliverAppBar( title: const Text('Title') ), new SliverList( diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index 3b977d772b..fa552eb67b 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -16,14 +16,14 @@ void main() { index = i; }, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, height: 100.0 ) ), - new Step( + const Step( title: const Text('Step 2'), content: const SizedBox( width: 100.0, @@ -44,14 +44,14 @@ void main() { child: new Material( child: new Stepper( steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, height: 100.0 ) ), - new Step( + const Step( title: const Text('Step 2'), content: const SizedBox( width: 200.0, @@ -73,14 +73,14 @@ void main() { child: new Stepper( currentStep: 1, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, height: 100.0 ) ), - new Step( + const Step( title: const Text('Step 2'), content: const SizedBox( width: 200.0, @@ -108,7 +108,7 @@ void main() { child: new Stepper( type: StepperType.horizontal, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, @@ -131,11 +131,11 @@ void main() { child: new Stepper( type: StepperType.horizontal, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const Text('A') ), - new Step( + const Step( title: const Text('Step 2'), content: const Text('B') ) @@ -153,11 +153,11 @@ void main() { currentStep: 1, type: StepperType.horizontal, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const Text('A') ), - new Step( + const Step( title: const Text('Step 2'), content: const Text('B') ) @@ -185,14 +185,14 @@ void main() { cancelPressed = true; }, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, height: 100.0 ) ), - new Step( + const Step( title: const Text('Step 2'), content: const SizedBox( width: 200.0, @@ -221,14 +221,14 @@ void main() { index = i; }, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, height: 100.0 ) ), - new Step( + const Step( title: const Text('Step 2'), state: StepState.disabled, content: const SizedBox( @@ -250,21 +250,21 @@ void main() { new Material( child: new Stepper( steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, height: 300.0 ) ), - new Step( + const Step( title: const Text('Step 2'), content: const SizedBox( width: 100.0, height: 300.0 ) ), - new Step( + const Step( title: const Text('Step 3'), content: const SizedBox( width: 100.0, @@ -285,21 +285,21 @@ void main() { child: new Stepper( currentStep: 2, steps: [ - new Step( + const Step( title: const Text('Step 1'), content: const SizedBox( width: 100.0, height: 300.0 ) ), - new Step( + const Step( title: const Text('Step 2'), content: const SizedBox( width: 100.0, height: 300.0 ) ), - new Step( + const Step( title: const Text('Step 3'), content: const SizedBox( width: 100.0, @@ -321,7 +321,7 @@ void main() { child: new Material( child: new Stepper( steps: [ - new Step( + const Step( title: const Text('A'), state: StepState.complete, content: const SizedBox( @@ -329,7 +329,7 @@ void main() { height: 100.0 ) ), - new Step( + const Step( title: const Text('B'), content: const SizedBox( width: 100.0, @@ -352,7 +352,7 @@ void main() { child: new Material( child: new Stepper( steps: [ - new Step( + const Step( title: const Text('A'), state: StepState.error, content: const SizedBox( diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 75b321f6c0..f86d476785 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -125,8 +125,8 @@ void main() { testWidgets('Cursor blinks', (WidgetTester tester) async { Widget builder() { - return new Center( - child: new Material( + return const Center( + child: const Material( child: const TextField( decoration: const InputDecoration( hintText: 'Placeholder', @@ -169,8 +169,8 @@ void main() { testWidgets('obscureText control test', (WidgetTester tester) async { Widget builder() { - return new Center( - child: new Material( + return const Center( + child: const Material( child: const TextField( obscureText: true, decoration: const InputDecoration( @@ -811,8 +811,8 @@ void main() { testWidgets('No space between Input icon and text', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new Material( + const Center( + child: const Material( child: const TextField( decoration: const InputDecoration( icon: const Icon(Icons.phone), @@ -830,8 +830,8 @@ void main() { testWidgets('Collapsed hint text placement', (WidgetTester tester) async { await tester.pumpWidget( - overlay(new Center( - child: new Material( + overlay(const Center( + child: const Material( child: const TextField( decoration: const InputDecoration.collapsed( hintText: 'hint', diff --git a/packages/flutter/test/material/theme_test.dart b/packages/flutter/test/material/theme_test.dart index 3159bf58dc..6a5ff1d1ac 100644 --- a/packages/flutter/test/material/theme_test.dart +++ b/packages/flutter/test/material/theme_test.dart @@ -103,7 +103,7 @@ void main() { onChanged: (String newValue) { }, value: 'menuItem', items: >[ - new DropdownMenuItem( + const DropdownMenuItem( value: 'menuItem', child: const Text('menuItem'), ), diff --git a/packages/flutter/test/material/two_level_list_test.dart b/packages/flutter/test/material/two_level_list_test.dart index db29877f80..ce2a24ba9a 100644 --- a/packages/flutter/test/material/two_level_list_test.dart +++ b/packages/flutter/test/material/two_level_list_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; void main() { testWidgets('TwoLevelList default control', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new TwoLevelList())); + await tester.pumpWidget(const Center(child: const TwoLevelList())); await tester.pumpWidget( new Material( @@ -41,8 +41,8 @@ void main() { key: sublistKey, title: const Text('Sublist'), children: [ - new TwoLevelListItem(title: const Text('0')), - new TwoLevelListItem(title: const Text('1')) + const TwoLevelListItem(title: const Text('0')), + const TwoLevelListItem(title: const Text('1')) ] ), new TwoLevelListItem(title: const Text('Bottom'), key: bottomKey) @@ -100,8 +100,8 @@ void main() { didChangeOpen = opened; }, children: [ - new TwoLevelListItem(title: const Text('0')), - new TwoLevelListItem(title: const Text('1')) + const TwoLevelListItem(title: const Text('0')), + const TwoLevelListItem(title: const Text('1')) ] ), ] diff --git a/packages/flutter/test/widgets/animated_cross_fade_test.dart b/packages/flutter/test/widgets/animated_cross_fade_test.dart index 1c4a44f495..70ad32b13d 100644 --- a/packages/flutter/test/widgets/animated_cross_fade_test.dart +++ b/packages/flutter/test/widgets/animated_cross_fade_test.dart @@ -9,8 +9,8 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('AnimatedCrossFade test', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new AnimatedCrossFade( + const Center( + child: const AnimatedCrossFade( firstChild: const SizedBox( width: 100.0, height: 100.0 @@ -31,8 +31,8 @@ void main() { expect(box.size.height, equals(100.0)); await tester.pumpWidget( - new Center( - child: new AnimatedCrossFade( + const Center( + child: const AnimatedCrossFade( firstChild: const SizedBox( width: 100.0, height: 100.0 @@ -57,8 +57,8 @@ void main() { testWidgets('AnimatedCrossFade test showSecond', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new AnimatedCrossFade( + const Center( + child: const AnimatedCrossFade( firstChild: const SizedBox( width: 100.0, height: 100.0 diff --git a/packages/flutter/test/widgets/async_test.dart b/packages/flutter/test/widgets/async_test.dart index e87df07dc9..684c8b2a76 100644 --- a/packages/flutter/test/widgets/async_test.dart +++ b/packages/flutter/test/widgets/async_test.dart @@ -20,13 +20,13 @@ void main() { }); test('requiring data fails if there is an error', () { expect( - () => new AsyncSnapshot.withError(ConnectionState.done, 'error').requireData, + () => const AsyncSnapshot.withError(ConnectionState.done, 'error').requireData, throwsA(equals('error')), ); }); test('requiring data fails if snapshot has neither data nor error', () { expect( - () => new AsyncSnapshot.nothing().requireData, + () => const AsyncSnapshot.nothing().requireData, throwsStateError, ); }); diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 40ba033010..7aa54107e7 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -200,7 +200,7 @@ void main() { home: new Material( child: new ListView( children: [ - new Hero(tag: 'a', child: const Text('foo')), + const Hero(tag: 'a', child: const Text('foo')), new Builder(builder: (BuildContext context) { return new FlatButton(child: const Text('two'), onPressed: () => Navigator.push(context, route)); }) @@ -393,8 +393,8 @@ void main() { home: new Material( child: new ListView( children: [ - new Hero(tag: 'a', child: const Text('a')), - new Hero(tag: 'a', child: const Text('a too')), + const Hero(tag: 'a', child: const Text('a')), + const Hero(tag: 'a', child: const Text('a too')), new Builder( builder: (BuildContext context) { return new FlatButton( @@ -929,8 +929,8 @@ void main() { return new Material( child: new ListView( children: [ - new Card( - child: new Hero( + const Card( + child: const Hero( tag: 'H', child: const SizedBox( height: 200.0, @@ -955,8 +955,8 @@ void main() { builder: (BuildContext context) { // Navigator.push() needs context return new ListView( children: [ - new Card( - child: new Hero( + const Card( + child: const Hero( tag: 'H', child: const SizedBox( height: 100.0, diff --git a/packages/flutter/test/widgets/page_transitions_test.dart b/packages/flutter/test/widgets/page_transitions_test.dart index e5a4ed83c1..942b8ff960 100644 --- a/packages/flutter/test/widgets/page_transitions_test.dart +++ b/packages/flutter/test/widgets/page_transitions_test.dart @@ -137,7 +137,7 @@ void main() { key: containerKey1, body: new Container( decoration: const BoxDecoration(backgroundColor: const Color(0xff00ffff)), - child: new Hero( + child: const Hero( tag: kHeroTag, child: const Text('Home') ) @@ -148,7 +148,7 @@ void main() { body: new Container( padding: const EdgeInsets.all(100.0), decoration: const BoxDecoration(backgroundColor: const Color(0xffff00ff)), - child: new Hero( + child: const Hero( tag: kHeroTag, child: const Text('Settings') ) diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index 282cbedaec..a58f79a264 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Text respects media query', (WidgetTester tester) async { - await tester.pumpWidget(new MediaQuery( + await tester.pumpWidget(const MediaQuery( data: const MediaQueryData(textScaleFactor: 1.5), child: const Center( child: const Text('Hello') diff --git a/packages/flutter/test/widgets/ticker_provider_test.dart b/packages/flutter/test/widgets/ticker_provider_test.dart index 453989c929..ff273917a3 100644 --- a/packages/flutter/test/widgets/ticker_provider_test.dart +++ b/packages/flutter/test/widgets/ticker_provider_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; void main() { testWidgets('TickerMode', (WidgetTester tester) async { - final Widget widget = new TickerMode( + final Widget widget = const TickerMode( enabled: false, child: const LinearProgressIndicator() ); @@ -17,14 +17,14 @@ void main() { expect(tester.binding.transientCallbackCount, 0); - await tester.pumpWidget(new TickerMode( + await tester.pumpWidget(const TickerMode( enabled: true, child: const LinearProgressIndicator() )); expect(tester.binding.transientCallbackCount, 1); - await tester.pumpWidget(new TickerMode( + await tester.pumpWidget(const TickerMode( enabled: false, child: const LinearProgressIndicator() ));