Commit 83fce211 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

More const immutable classes (#9544)

* more widget const constructors

* prefer const constructors

* address review comments
parent 054c9379
...@@ -176,9 +176,9 @@ class FancyImageItem extends StatelessWidget { ...@@ -176,9 +176,9 @@ class FancyImageItem extends StatelessWidget {
new ItemDescription(), new ItemDescription(),
new ItemImageBox(), new ItemImageBox(),
new InfoBar(), new InfoBar(),
new Padding( const Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: new Divider() child: const Divider()
), ),
new IconBar(), new IconBar(),
new FatDivider() new FatDivider()
...@@ -198,9 +198,9 @@ class FancyGalleryItem extends StatelessWidget { ...@@ -198,9 +198,9 @@ class FancyGalleryItem extends StatelessWidget {
const UserHeader('Ali Connors'), const UserHeader('Ali Connors'),
new ItemGalleryBox(index), new ItemGalleryBox(index),
new InfoBar(), new InfoBar(),
new Padding( const Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: new Divider() child: const Divider()
), ),
new IconBar(), new IconBar(),
new FatDivider() new FatDivider()
...@@ -599,7 +599,7 @@ class GalleryDrawer extends StatelessWidget { ...@@ -599,7 +599,7 @@ class GalleryDrawer extends StatelessWidget {
onChanged: (bool value) { _changeTheme(context, value); }, onChanged: (bool value) { _changeTheme(context, value); },
), ),
), ),
new Divider(), const Divider(),
new ListTile( new ListTile(
leading: const Icon(Icons.hourglass_empty), leading: const Icon(Icons.hourglass_empty),
title: const Text('Animate Slowly'), title: const Text('Animate Slowly'),
......
...@@ -93,20 +93,20 @@ class CardCollectionState extends State<CardCollection> { ...@@ -93,20 +93,20 @@ class CardCollectionState extends State<CardCollection> {
buildDrawerCheckbox("Fixed size cards", _fixedSizeCards, _toggleFixedSizeCards), buildDrawerCheckbox("Fixed size cards", _fixedSizeCards, _toggleFixedSizeCards),
buildDrawerCheckbox("Let the sun shine", _sunshine, _toggleSunshine), buildDrawerCheckbox("Let the sun shine", _sunshine, _toggleSunshine),
buildDrawerCheckbox("Vary font sizes", _varyFontSizes, _toggleVaryFontSizes, enabled: !_editable), buildDrawerCheckbox("Vary font sizes", _varyFontSizes, _toggleVaryFontSizes, enabled: !_editable),
new Divider(), const Divider(),
buildDrawerColorRadioItem("Deep Purple", Colors.deepPurple, _primaryColor, _selectColor), buildDrawerColorRadioItem("Deep Purple", Colors.deepPurple, _primaryColor, _selectColor),
buildDrawerColorRadioItem("Green", Colors.green, _primaryColor, _selectColor), buildDrawerColorRadioItem("Green", Colors.green, _primaryColor, _selectColor),
buildDrawerColorRadioItem("Amber", Colors.amber, _primaryColor, _selectColor), buildDrawerColorRadioItem("Amber", Colors.amber, _primaryColor, _selectColor),
buildDrawerColorRadioItem("Teal", Colors.teal, _primaryColor, _selectColor), buildDrawerColorRadioItem("Teal", Colors.teal, _primaryColor, _selectColor),
new Divider(), const Divider(),
buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code), buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code),
buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.endToStart, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back), buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.endToStart, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back),
buildDrawerDirectionRadioItem("Dismiss right", DismissDirection.startToEnd, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_forward), 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("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("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), buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable),
new Divider(), const Divider(),
new ListTile( new ListTile(
leading: const Icon(Icons.dvr), leading: const Icon(Icons.dvr),
onTap: () { debugDumpApp(); debugDumpRenderTree(); }, onTap: () { debugDumpApp(); debugDumpRenderTree(); },
......
...@@ -525,7 +525,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> { ...@@ -525,7 +525,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
new Positioned( new Positioned(
top: statusBarHeight, top: statusBarHeight,
left: 0.0, left: 0.0,
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(color: Colors.white), data: const IconThemeData(color: Colors.white),
child: const BackButton(), child: const BackButton(),
), ),
......
...@@ -126,7 +126,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -126,7 +126,7 @@ class _CalculatorState extends State<Calculator> {
flex: 2, flex: 2,
child: new CalcDisplay(content: _expression.toString()) child: new CalcDisplay(content: _expression.toString())
), ),
new Divider(height: 1.0), const Divider(height: 1.0),
new Expanded( new Expanded(
flex: 3, flex: 3,
child: new KeyPad(calcState: this) child: new KeyPad(calcState: this)
......
...@@ -116,7 +116,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -116,7 +116,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: const Icon(Icons.create), icon: const Icon(Icons.create),
tooltip: 'Edit', tooltip: 'Edit',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('This is actually just a demo. Editing isn\'t supported.') content: const Text('This is actually just a demo. Editing isn\'t supported.')
)); ));
}, },
...@@ -176,7 +176,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -176,7 +176,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.message, icon: Icons.message,
tooltip: 'Send message', tooltip: 'Send message',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('Pretend that this opened your SMS application.') content: const Text('Pretend that this opened your SMS application.')
)); ));
}, },
...@@ -189,7 +189,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -189,7 +189,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.message, icon: Icons.message,
tooltip: 'Send message', tooltip: 'Send message',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('In this demo, this button doesn\'t do anything.') content: const Text('In this demo, this button doesn\'t do anything.')
)); ));
}, },
...@@ -202,7 +202,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -202,7 +202,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.message, icon: Icons.message,
tooltip: 'Send message', tooltip: 'Send message',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('Imagine if you will, a messaging application.') content: const Text('Imagine if you will, a messaging application.')
)); ));
}, },
...@@ -220,7 +220,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -220,7 +220,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.email, icon: Icons.email,
tooltip: 'Send personal e-mail', tooltip: 'Send personal e-mail',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('Here, your e-mail application would open.') content: const Text('Here, your e-mail application would open.')
)); ));
}, },
...@@ -233,7 +233,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -233,7 +233,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.email, icon: Icons.email,
tooltip: 'Send work e-mail', tooltip: 'Send work e-mail',
onPressed: () { 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.') content: const Text('This is a demo, so this button does not actually work.')
)); ));
}, },
...@@ -251,7 +251,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -251,7 +251,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.map, icon: Icons.map,
tooltip: 'Open map', tooltip: 'Open map',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('This would show a map of San Francisco.') content: const Text('This would show a map of San Francisco.')
)); ));
}, },
...@@ -265,7 +265,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -265,7 +265,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.map, icon: Icons.map,
tooltip: 'Open map', tooltip: 'Open map',
onPressed: () { onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar( _scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('This would show a map of Mountain View.') content: const Text('This would show a map of Mountain View.')
)); ));
}, },
...@@ -279,7 +279,7 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -279,7 +279,7 @@ class ContactsDemoState extends State<ContactsDemo> {
icon: Icons.map, icon: Icons.map,
tooltip: 'Open map', tooltip: 'Open map',
onPressed: () { 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.') content: const Text('This would also show a map, if this was not a demo.')
)); ));
}, },
......
...@@ -14,8 +14,8 @@ class CupertinoProgressIndicatorDemo extends StatelessWidget { ...@@ -14,8 +14,8 @@ class CupertinoProgressIndicatorDemo extends StatelessWidget {
appBar: new AppBar( appBar: new AppBar(
title: const Text('Cupertino Activity Indicator'), title: const Text('Cupertino Activity Indicator'),
), ),
body: new Center( body: const Center(
child: new CupertinoActivityIndicator(), child: const CupertinoActivityIndicator(),
), ),
); );
} }
......
...@@ -49,7 +49,7 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> { ...@@ -49,7 +49,7 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
setState(() {_pressedCount++;}); setState(() {_pressedCount++;});
} }
), ),
new CupertinoButton( const CupertinoButton(
child: const Text('Disabled'), child: const Text('Disabled'),
onPressed: null, onPressed: null,
), ),
...@@ -65,7 +65,7 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> { ...@@ -65,7 +65,7 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
} }
), ),
const Padding(padding: const EdgeInsets.all(12.0)), const Padding(padding: const EdgeInsets.all(12.0)),
new CupertinoButton( const CupertinoButton(
child: const Text('Disabled'), child: const Text('Disabled'),
color: _kBlue, color: _kBlue,
onPressed: null, onPressed: null,
......
...@@ -121,7 +121,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -121,7 +121,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
// Perform some action // Perform some action
}, },
), ),
new FlatButton( const FlatButton(
child: const Text('DISABLED'), child: const Text('DISABLED'),
onPressed: null, onPressed: null,
) )
......
...@@ -67,7 +67,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -67,7 +67,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
void _showNotImplementedMessage() { void _showNotImplementedMessage() {
Navigator.of(context).pop(); // Dismiss the drawer. 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") content: const Text("The drawer's items don't do anything")
)); ));
} }
......
...@@ -108,7 +108,7 @@ class CollapsibleBody extends StatelessWidget { ...@@ -108,7 +108,7 @@ class CollapsibleBody extends StatelessWidget {
) )
) )
), ),
new Divider(height: 1.0), const Divider(height: 1.0),
new Container( new Container(
padding: const EdgeInsets.symmetric(vertical: 16.0), padding: const EdgeInsets.symmetric(vertical: 16.0),
child: new Row( child: new Row(
......
...@@ -103,13 +103,13 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> { ...@@ -103,13 +103,13 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
}, },
background: new Container( background: new Container(
color: theme.primaryColor, color: theme.primaryColor,
child: new ListTile( child: const ListTile(
leading: const Icon(Icons.delete, color: Colors.white, size: 36.0) leading: const Icon(Icons.delete, color: Colors.white, size: 36.0)
) )
), ),
secondaryBackground: new Container( secondaryBackground: new Container(
color: theme.primaryColor, color: theme.primaryColor,
child: new ListTile( child: const ListTile(
trailing: const Icon(Icons.archive, color: Colors.white, size: 36.0) trailing: const Icon(Icons.archive, color: Colors.white, size: 36.0)
) )
), ),
......
...@@ -119,31 +119,31 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -119,31 +119,31 @@ class MenuDemoState extends State<MenuDemo> {
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onSelected: showMenuSelection, onSelected: showMenuSelection,
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
new PopupMenuItem<String>( const PopupMenuItem<String>(
value: 'Preview', value: 'Preview',
child: new ListTile( child: const ListTile(
leading: const Icon(Icons.visibility), leading: const Icon(Icons.visibility),
title: const Text('Preview') title: const Text('Preview')
) )
), ),
new PopupMenuItem<String>( const PopupMenuItem<String>(
value: 'Share', value: 'Share',
child: new ListTile( child: const ListTile(
leading: const Icon(Icons.person_add), leading: const Icon(Icons.person_add),
title: const Text('Share') title: const Text('Share')
) )
), ),
new PopupMenuItem<String>( const PopupMenuItem<String>(
value: 'Get Link', value: 'Get Link',
child: new ListTile( child: const ListTile(
leading: const Icon(Icons.link), leading: const Icon(Icons.link),
title: const Text('Get link') title: const Text('Get link')
) )
), ),
const PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771 const PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771
new PopupMenuItem<String>( const PopupMenuItem<String>(
value: 'Remove', value: 'Remove',
child: new ListTile( child: const ListTile(
leading: const Icon(Icons.delete), leading: const Icon(Icons.delete),
title: const Text('Remove') title: const Text('Remove')
) )
......
...@@ -43,7 +43,7 @@ class _SliderDemoState extends State<SliderDemo> { ...@@ -43,7 +43,7 @@ class _SliderDemoState extends State<SliderDemo> {
new Column( new Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget> [ children: <Widget> [
new Slider(value: 0.25, thumbOpenAtMin: true, onChanged: null), const Slider(value: 0.25, thumbOpenAtMin: true, onChanged: null),
const Text('Disabled'), const Text('Disabled'),
] ]
), ),
......
...@@ -46,7 +46,7 @@ class TooltipDemo extends StatelessWidget { ...@@ -46,7 +46,7 @@ class TooltipDemo extends StatelessWidget {
color: theme.iconTheme.color, color: theme.iconTheme.color,
tooltip: 'Place a phone call', tooltip: 'Place a phone call',
onPressed: () { onPressed: () {
Scaffold.of(context).showSnackBar(new SnackBar( Scaffold.of(context).showSnackBar(const SnackBar(
content: const Text('That was an ordinary tap.') content: const Text('That was an ordinary tap.')
)); ));
} }
......
...@@ -14,19 +14,19 @@ class TwoLevelListDemo extends StatelessWidget { ...@@ -14,19 +14,19 @@ class TwoLevelListDemo extends StatelessWidget {
body: new TwoLevelList( body: new TwoLevelList(
type: MaterialListType.oneLine, type: MaterialListType.oneLine,
children: <Widget>[ children: <Widget>[
new TwoLevelListItem(title: const Text('Top')), const TwoLevelListItem(title: const Text('Top')),
new TwoLevelSublist( new TwoLevelSublist(
title: const Text('Sublist'), title: const Text('Sublist'),
backgroundColor: Theme.of(context).accentColor.withOpacity(0.025), backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
children: <Widget>[ children: <Widget>[
new TwoLevelListItem(title: const Text('One')), const TwoLevelListItem(title: const Text('One')),
new TwoLevelListItem(title: const Text('Two')), const TwoLevelListItem(title: const Text('Two')),
// https://en.wikipedia.org/wiki/Free_Four // https://en.wikipedia.org/wiki/Free_Four
new TwoLevelListItem(title: const Text('Free')), const TwoLevelListItem(title: const Text('Free')),
new TwoLevelListItem(title: const Text('Four')) const TwoLevelListItem(title: const Text('Four'))
] ]
), ),
new TwoLevelListItem(title: const Text('Bottom')) const TwoLevelListItem(title: const Text('Bottom'))
] ]
) )
); );
......
...@@ -84,7 +84,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -84,7 +84,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
floatingActionButton: new FloatingActionButton( floatingActionButton: new FloatingActionButton(
child: const Icon(Icons.edit), child: const Icon(Icons.edit),
onPressed: () { onPressed: () {
scaffoldKey.currentState.showSnackBar(new SnackBar( scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('Not supported.'), content: const Text('Not supported.'),
)); ));
}, },
...@@ -108,7 +108,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -108,7 +108,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
icon: const Icon(Icons.search), icon: const Icon(Icons.search),
tooltip: 'Search', tooltip: 'Search',
onPressed: () { onPressed: () {
scaffoldKey.currentState.showSnackBar(new SnackBar( scaffoldKey.currentState.showSnackBar(const SnackBar(
content: const Text('Not supported.'), content: const Text('Not supported.'),
)); ));
}, },
......
...@@ -82,7 +82,7 @@ class ShrinePageState extends State<ShrinePage> { ...@@ -82,7 +82,7 @@ class ShrinePageState extends State<ShrinePage> {
void _emptyCart() { void _emptyCart() {
widget.shoppingCart.clear(); 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 @override
......
...@@ -254,10 +254,10 @@ class GalleryDrawer extends StatelessWidget { ...@@ -254,10 +254,10 @@ class GalleryDrawer extends StatelessWidget {
new GalleryDrawerHeader(light: useLightTheme), new GalleryDrawerHeader(light: useLightTheme),
lightThemeItem, lightThemeItem,
darkThemeItem, darkThemeItem,
new Divider(), const Divider(),
mountainViewItem, mountainViewItem,
cupertinoItem, cupertinoItem,
new Divider(), const Divider(),
animateSlowlyItem, animateSlowlyItem,
// index 8, optional: Performance Overlay // index 8, optional: Performance Overlay
sendFeedbackItem, sendFeedbackItem,
......
...@@ -44,7 +44,7 @@ new FlatButton( ...@@ -44,7 +44,7 @@ new FlatButton(
// Create a disabled button. // Create a disabled button.
// Buttons are disabled when onPressed isn't // Buttons are disabled when onPressed isn't
// specified or is null. // specified or is null.
new FlatButton( const FlatButton(
child: const Text('BUTTON TITLE'), child: const Text('BUTTON TITLE'),
onPressed: null onPressed: null
); );
......
...@@ -132,7 +132,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState ...@@ -132,7 +132,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState
for (GalleryItem galleryItem in kAllGalleryItems) { for (GalleryItem galleryItem in kAllGalleryItems) {
if (category != galleryItem.category) { if (category != galleryItem.category) {
if (category != null) if (category != null)
listItems.add(new Divider()); listItems.add(const Divider());
listItems.add( listItems.add(
new Container( new Container(
height: 48.0, height: 48.0,
...@@ -166,7 +166,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState ...@@ -166,7 +166,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState
), ),
body: new CustomScrollView( body: new CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[
new SliverAppBar( const SliverAppBar(
pinned: true, pinned: true,
expandedHeight: _kFlexibleSpaceMaxHeight, expandedHeight: _kFlexibleSpaceMaxHeight,
flexibleSpace: const FlexibleSpaceBar( flexibleSpace: const FlexibleSpaceBar(
......
...@@ -118,12 +118,12 @@ class StockHomeState extends State<StockHome> { ...@@ -118,12 +118,12 @@ class StockHomeState extends State<StockHome> {
child: new ListView( child: new ListView(
children: <Widget>[ children: <Widget>[
const DrawerHeader(child: const Center(child: const Text('Stocks'))), const DrawerHeader(child: const Center(child: const Text('Stocks'))),
new ListTile( const ListTile(
leading: const Icon(Icons.assessment), leading: const Icon(Icons.assessment),
title: const Text('Stock List'), title: const Text('Stock List'),
selected: true, selected: true,
), ),
new ListTile( const ListTile(
leading: const Icon(Icons.account_balance), leading: const Icon(Icons.account_balance),
title: const Text('Account Balance'), title: const Text('Account Balance'),
enabled: false, enabled: false,
...@@ -142,7 +142,7 @@ class StockHomeState extends State<StockHome> { ...@@ -142,7 +142,7 @@ class StockHomeState extends State<StockHome> {
} }
}, },
), ),
new Divider(), const Divider(),
new ListTile( new ListTile(
leading: const Icon(Icons.thumb_up), leading: const Icon(Icons.thumb_up),
title: const Text('Optimistic'), title: const Text('Optimistic'),
...@@ -167,7 +167,7 @@ class StockHomeState extends State<StockHome> { ...@@ -167,7 +167,7 @@ class StockHomeState extends State<StockHome> {
_handleStockModeChange(StockMode.pessimistic); _handleStockModeChange(StockMode.pessimistic);
}, },
), ),
new Divider(), const Divider(),
new ListTile( new ListTile(
leading: const Icon(Icons.settings), leading: const Icon(Icons.settings),
title: const Text('Settings'), title: const Text('Settings'),
......
...@@ -13,12 +13,11 @@ import 'package:flutter/widgets.dart'; ...@@ -13,12 +13,11 @@ import 'package:flutter/widgets.dart';
/// * <https://developer.apple.com/ios/human-interface-guidelines/ui-controls/progress-indicators/#activity-indicators> /// * <https://developer.apple.com/ios/human-interface-guidelines/ui-controls/progress-indicators/#activity-indicators>
class CupertinoActivityIndicator extends StatefulWidget { class CupertinoActivityIndicator extends StatefulWidget {
/// Creates an iOS-style activity indicator. /// Creates an iOS-style activity indicator.
CupertinoActivityIndicator({ const CupertinoActivityIndicator({
Key key, Key key,
this.animating: true, this.animating: true,
}) : super(key: key) { }) : assert(animating != null),
assert(animating != null); super(key: key);
}
/// Whether the activity indicator is running its animation. /// Whether the activity indicator is running its animation.
/// ///
......
...@@ -42,16 +42,14 @@ const EdgeInsets _kBackgroundButtonPadding = ...@@ -42,16 +42,14 @@ const EdgeInsets _kBackgroundButtonPadding =
/// * <https://developer.apple.com/ios/human-interface-guidelines/ui-controls/buttons/> /// * <https://developer.apple.com/ios/human-interface-guidelines/ui-controls/buttons/>
class CupertinoButton extends StatefulWidget { class CupertinoButton extends StatefulWidget {
/// Creates an iOS-style button. /// Creates an iOS-style button.
CupertinoButton({ const CupertinoButton({
@required this.child, @required this.child,
this.padding, this.padding,
this.color, this.color,
this.minSize: 44.0, this.minSize: 44.0,
this.pressedOpacity: 0.1, this.pressedOpacity: 0.1,
@required this.onPressed, @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. /// The widget below this widget in the tree.
/// ///
......
...@@ -177,13 +177,11 @@ const Color _kDestructiveActionColor = const Color(0xFFFF3B30); ...@@ -177,13 +177,11 @@ const Color _kDestructiveActionColor = const Color(0xFFFF3B30);
/// * [CupertinoAlertDialog] /// * [CupertinoAlertDialog]
class CupertinoDialogAction extends StatelessWidget { class CupertinoDialogAction extends StatelessWidget {
/// Creates an action for an iOS-style dialog. /// Creates an action for an iOS-style dialog.
CupertinoDialogAction({ const CupertinoDialogAction({
this.onPressed, this.onPressed,
this.isDestructive: false, this.isDestructive: false,
@required this.child, @required this.child,
}) { }) : assert(child != null);
assert(child != null);
}
/// The callback that is called when the button is tapped or otherwise activated. /// The callback that is called when the button is tapped or otherwise activated.
/// ///
......
...@@ -41,7 +41,7 @@ class CupertinoSlider extends StatefulWidget { ...@@ -41,7 +41,7 @@ class CupertinoSlider extends StatefulWidget {
/// ///
/// * [value] determines currently selected value for this slider. /// * [value] determines currently selected value for this slider.
/// * [onChanged] is called when the user selects a new value for the slider. /// * [onChanged] is called when the user selects a new value for the slider.
CupertinoSlider({ const CupertinoSlider({
Key key, Key key,
@required this.value, @required this.value,
@required this.onChanged, @required this.onChanged,
...@@ -49,13 +49,12 @@ class CupertinoSlider extends StatefulWidget { ...@@ -49,13 +49,12 @@ class CupertinoSlider extends StatefulWidget {
this.max: 1.0, this.max: 1.0,
this.divisions, this.divisions,
this.activeColor: const Color(0xFF027AFF), this.activeColor: const Color(0xFF027AFF),
}) : super(key: key) { }) : assert(value != null),
assert(value != null); assert(min != null),
assert(min != null); assert(max != null),
assert(max != null); assert(value >= min && value <= max),
assert(value >= min && value <= max); assert(divisions == null || divisions > 0),
assert(divisions == null || divisions > 0); super(key: key);
}
/// The currently selected value for this slider. /// The currently selected value for this slider.
/// ///
......
...@@ -677,7 +677,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { ...@@ -677,7 +677,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
/// * <https://material.google.com/layout/structure.html#structure-toolbars> /// * <https://material.google.com/layout/structure.html#structure-toolbars>
class SliverAppBar extends StatefulWidget { class SliverAppBar extends StatefulWidget {
/// Creates a material design app bar that can be placed in a [CustomScrollView]. /// Creates a material design app bar that can be placed in a [CustomScrollView].
SliverAppBar({ const SliverAppBar({
Key key, Key key,
this.leading, this.leading,
this.title, this.title,
...@@ -695,13 +695,12 @@ class SliverAppBar extends StatefulWidget { ...@@ -695,13 +695,12 @@ class SliverAppBar extends StatefulWidget {
this.floating: false, this.floating: false,
this.pinned: false, this.pinned: false,
this.snap: false, this.snap: false,
}) : super(key: key) { }) : assert(primary != null),
assert(primary != null); assert(floating != null),
assert(floating != null); assert(pinned != null),
assert(pinned != null); assert(pinned && floating ? bottom != null : true),
assert(pinned && floating ? bottom != null : true); assert(snap != null),
assert(snap != null); super(key: key);
}
/// A widget to display before the [title]. /// A widget to display before the [title].
/// ///
......
...@@ -47,15 +47,14 @@ class BottomSheet extends StatefulWidget { ...@@ -47,15 +47,14 @@ class BottomSheet extends StatefulWidget {
/// Typically, bottom sheets are created implicitly by /// Typically, bottom sheets are created implicitly by
/// [Scaffold.showBottomSheet], for persistent bottom sheets, or by /// [Scaffold.showBottomSheet], for persistent bottom sheets, or by
/// [showModalBottomSheet], for modal bottom sheets. /// [showModalBottomSheet], for modal bottom sheets.
BottomSheet({ const BottomSheet({
Key key, Key key,
this.animationController, this.animationController,
@required this.onClosing, @required this.onClosing,
@required this.builder @required this.builder
}) : super(key: key) { }) : assert(onClosing != null),
assert(onClosing != null); assert(builder != null),
assert(builder != null); super(key: key);
}
/// The animation that controls the bottom sheet's position. /// The animation that controls the bottom sheet's position.
/// ///
......
...@@ -103,19 +103,18 @@ class _CheckboxState extends State<Checkbox> with TickerProviderStateMixin { ...@@ -103,19 +103,18 @@ class _CheckboxState extends State<Checkbox> with TickerProviderStateMixin {
} }
class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget { class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget {
_CheckboxRenderObjectWidget({ const _CheckboxRenderObjectWidget({
Key key, Key key,
@required this.value, @required this.value,
@required this.activeColor, @required this.activeColor,
@required this.inactiveColor, @required this.inactiveColor,
@required this.onChanged, @required this.onChanged,
@required this.vsync, @required this.vsync,
}) : super(key: key) { }) : assert(value != null),
assert(value != null); assert(activeColor != null),
assert(activeColor != null); assert(inactiveColor != null),
assert(inactiveColor != null); assert(vsync != null),
assert(vsync != null); super(key: key);
}
final bool value; final bool value;
final Color activeColor; final Color activeColor;
......
...@@ -44,17 +44,16 @@ const double _kDatePickerLandscapeHeight = _kMaxDayPickerHeight + _kDialogAction ...@@ -44,17 +44,16 @@ const double _kDatePickerLandscapeHeight = _kMaxDayPickerHeight + _kDialogAction
// Shows the selected date in large font and toggles between year and day mode // Shows the selected date in large font and toggles between year and day mode
class _DatePickerHeader extends StatelessWidget { class _DatePickerHeader extends StatelessWidget {
_DatePickerHeader({ const _DatePickerHeader({
Key key, Key key,
@required this.selectedDate, @required this.selectedDate,
@required this.mode, @required this.mode,
@required this.onModeChanged, @required this.onModeChanged,
@required this.orientation, @required this.orientation,
}) : super(key: key) { }) : assert(selectedDate != null),
assert(selectedDate != null); assert(mode != null),
assert(mode != null); assert(orientation != null),
assert(orientation != null); super(key: key);
}
final DateTime selectedDate; final DateTime selectedDate;
final _DatePickerMode mode; final _DatePickerMode mode;
......
...@@ -27,14 +27,13 @@ class Divider extends StatelessWidget { ...@@ -27,14 +27,13 @@ class Divider extends StatelessWidget {
/// Creates a material design divider. /// Creates a material design divider.
/// ///
/// The height must be at least 1.0 logical pixels. /// The height must be at least 1.0 logical pixels.
Divider({ const Divider({
Key key, Key key,
this.height: 16.0, this.height: 16.0,
this.indent: 0.0, this.indent: 0.0,
this.color this.color
}) : super(key: key) { }) : assert(height >= 1.0),
assert(height >= 1.0); super(key: key);
}
/// The divider's vertical extent. /// The divider's vertical extent.
/// ///
......
...@@ -116,12 +116,11 @@ class DrawerController extends StatefulWidget { ...@@ -116,12 +116,11 @@ class DrawerController extends StatefulWidget {
/// Rarely used directly. /// Rarely used directly.
/// ///
/// The [child] argument must not be null and is typically a [Drawer]. /// The [child] argument must not be null and is typically a [Drawer].
DrawerController({ const DrawerController({
GlobalKey key, GlobalKey key,
@required this.child @required this.child
}) : super(key: key) { }) : assert(child != null),
assert(child != null); super(key: key);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
/// ///
......
...@@ -333,13 +333,12 @@ class DropdownMenuItem<T> extends StatelessWidget { ...@@ -333,13 +333,12 @@ class DropdownMenuItem<T> extends StatelessWidget {
/// Creates an item for a dropdown menu. /// Creates an item for a dropdown menu.
/// ///
/// The [child] argument is required. /// The [child] argument is required.
DropdownMenuItem({ const DropdownMenuItem({
Key key, Key key,
this.value, this.value,
@required this.child, @required this.child,
}) : super(key: key) { }) : assert(child != null),
assert(child != null); super(key: key);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
/// ///
...@@ -370,12 +369,11 @@ class DropdownMenuItem<T> extends StatelessWidget { ...@@ -370,12 +369,11 @@ class DropdownMenuItem<T> extends StatelessWidget {
class DropdownButtonHideUnderline extends InheritedWidget { class DropdownButtonHideUnderline extends InheritedWidget {
/// Creates a [DropdownButtonHideUnderline]. A non-null [child] must /// Creates a [DropdownButtonHideUnderline]. A non-null [child] must
/// be given. /// be given.
DropdownButtonHideUnderline({ const DropdownButtonHideUnderline({
Key key, Key key,
@required Widget child, @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 /// Returns whether the underline of [DropdownButton] widgets should
/// be hidden. /// be hidden.
......
...@@ -21,17 +21,16 @@ import 'theme.dart'; ...@@ -21,17 +21,16 @@ import 'theme.dart';
class ExpandIcon extends StatefulWidget { class ExpandIcon extends StatefulWidget {
/// Creates an [ExpandIcon] with the given padding, and a callback that is /// Creates an [ExpandIcon] with the given padding, and a callback that is
/// triggered when the icon is pressed. /// triggered when the icon is pressed.
ExpandIcon({ const ExpandIcon({
Key key, Key key,
this.isExpanded: false, this.isExpanded: false,
this.size: 24.0, this.size: 24.0,
@required this.onPressed, @required this.onPressed,
this.padding: const EdgeInsets.all(8.0) this.padding: const EdgeInsets.all(8.0)
}) : super(key: key) { }) : assert(isExpanded != null),
assert(isExpanded != null); assert(size != null),
assert(size != null); assert(padding != null),
assert(padding != null); super(key: key);
}
/// Whether the icon is in an expanded state. /// Whether the icon is in an expanded state.
/// ///
......
...@@ -73,15 +73,14 @@ class ExpansionPanel { ...@@ -73,15 +73,14 @@ class ExpansionPanel {
class ExpansionPanelList extends StatelessWidget { class ExpansionPanelList extends StatelessWidget {
/// Creates an expansion panel list widget. The [expansionCallback] is /// Creates an expansion panel list widget. The [expansionCallback] is
/// triggered when an expansion panel expand/collapse button is pushed. /// triggered when an expansion panel expand/collapse button is pushed.
ExpansionPanelList({ const ExpansionPanelList({
Key key, Key key,
this.children: const <ExpansionPanel>[], this.children: const <ExpansionPanel>[],
this.expansionCallback, this.expansionCallback,
this.animationDuration: kThemeAnimationDuration this.animationDuration: kThemeAnimationDuration
}) : super(key: key) { }) : assert(children != null),
assert(children != null); assert(animationDuration != null),
assert(animationDuration != null); super(key: key);
}
/// The children of the expansion panel list. They are layed in a similar /// The children of the expansion panel list. They are layed in a similar
/// fashion to [ListBody]. /// fashion to [ListBody].
......
...@@ -47,7 +47,7 @@ class FlatButton extends StatelessWidget { ...@@ -47,7 +47,7 @@ class FlatButton extends StatelessWidget {
/// ///
/// The [child] argument is required and is typically a [Text] widget in all /// The [child] argument is required and is typically a [Text] widget in all
/// caps. /// caps.
FlatButton({ const FlatButton({
Key key, Key key,
@required this.onPressed, @required this.onPressed,
this.textColor, this.textColor,
...@@ -59,9 +59,8 @@ class FlatButton extends StatelessWidget { ...@@ -59,9 +59,8 @@ class FlatButton extends StatelessWidget {
this.textTheme, this.textTheme,
this.colorBrightness, this.colorBrightness,
@required this.child @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. /// The callback that is called when the button is tapped or otherwise activated.
/// ///
......
...@@ -21,14 +21,13 @@ class GridTile extends StatelessWidget { ...@@ -21,14 +21,13 @@ class GridTile extends StatelessWidget {
/// Creates a grid tile. /// Creates a grid tile.
/// ///
/// Must have a child. Does not typically have both a header and a footer. /// Must have a child. Does not typically have both a header and a footer.
GridTile({ const GridTile({
Key key, Key key,
this.header, this.header,
this.footer, this.footer,
@required this.child, @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. /// The widget to show over the top of this grid tile.
/// ///
......
...@@ -16,14 +16,13 @@ class IconTheme extends InheritedWidget { ...@@ -16,14 +16,13 @@ class IconTheme extends InheritedWidget {
/// descendant widgets. /// descendant widgets.
/// ///
/// Both [data] and [child] arguments must not be null. /// Both [data] and [child] arguments must not be null.
IconTheme({ const IconTheme({
Key key, Key key,
@required this.data, @required this.data,
@required Widget child @required Widget child
}) : super(key: key, child: child) { }) : assert(data != null),
assert(data != null); assert(child != null),
assert(child != null); super(key: key, child: child);
}
/// Creates an icon theme that controls the color, opacity, and size of /// Creates an icon theme that controls the color, opacity, and size of
/// descendant widgets, and merges in the current icon theme, if any. /// descendant widgets, and merges in the current icon theme, if any.
......
...@@ -463,15 +463,14 @@ class InputDecorator extends StatelessWidget { ...@@ -463,15 +463,14 @@ class InputDecorator extends StatelessWidget {
// Smoothly animate the label of an InputDecorator as the label // Smoothly animate the label of an InputDecorator as the label
// transitions between inline and caption. // transitions between inline and caption.
class _AnimatedLabel extends ImplicitlyAnimatedWidget { class _AnimatedLabel extends ImplicitlyAnimatedWidget {
_AnimatedLabel({ const _AnimatedLabel({
Key key, Key key,
this.text, this.text,
@required this.style, @required this.style,
Curve curve: Curves.linear, Curve curve: Curves.linear,
@required Duration duration, @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 String text;
final TextStyle style; final TextStyle style;
......
...@@ -158,7 +158,7 @@ class ListTile extends StatelessWidget { ...@@ -158,7 +158,7 @@ class ListTile extends StatelessWidget {
/// If [isThreeLine] is true, then [subtitle] must not be null. /// If [isThreeLine] is true, then [subtitle] must not be null.
/// ///
/// Requires one of its ancestors to be a [Material] widget. /// Requires one of its ancestors to be a [Material] widget.
ListTile({ const ListTile({
Key key, Key key,
this.leading, this.leading,
this.title, this.title,
...@@ -170,11 +170,10 @@ class ListTile extends StatelessWidget { ...@@ -170,11 +170,10 @@ class ListTile extends StatelessWidget {
this.onTap, this.onTap,
this.onLongPress, this.onLongPress,
this.selected: false, this.selected: false,
}) : super(key: key) { }) : assert(isThreeLine != null),
assert(isThreeLine != null); assert(enabled != null),
assert(enabled != null); assert(selected != null),
assert(selected != null); super(key: key);
}
/// A widget to display before the title. /// A widget to display before the title.
/// ///
......
...@@ -110,7 +110,7 @@ class Material extends StatefulWidget { ...@@ -110,7 +110,7 @@ class Material extends StatefulWidget {
/// Creates a piece of material. /// Creates a piece of material.
/// ///
/// The [type] and the [elevation] arguments must not be null. /// The [type] and the [elevation] arguments must not be null.
Material({ const Material({
Key key, Key key,
this.type: MaterialType.canvas, this.type: MaterialType.canvas,
this.elevation: 0, this.elevation: 0,
...@@ -118,11 +118,10 @@ class Material extends StatefulWidget { ...@@ -118,11 +118,10 @@ class Material extends StatefulWidget {
this.textStyle, this.textStyle,
this.borderRadius, this.borderRadius,
this.child, this.child,
}) : super(key: key) { }) : assert(type != null),
assert(type != null); assert(elevation != null),
assert(elevation != null); assert(!(identical(type, MaterialType.circle) && borderRadius != null)),
assert(type != MaterialType.circle || borderRadius == null); super(key: key);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
......
...@@ -34,12 +34,11 @@ abstract class MergeableMaterialItem { ...@@ -34,12 +34,11 @@ abstract class MergeableMaterialItem {
class MaterialSlice extends MergeableMaterialItem { class MaterialSlice extends MergeableMaterialItem {
/// Creates a slice of [Material] that's mergeable within a /// Creates a slice of [Material] that's mergeable within a
/// [MergeableMaterial]. /// [MergeableMaterial].
MaterialSlice({ const MaterialSlice({
@required LocalKey key, @required LocalKey key,
@required this.child, @required this.child,
}) : super(key) { }) : assert(key != null),
assert(key != null); super(key);
}
/// The contents of this slice. /// The contents of this slice.
final Widget child; final Widget child;
...@@ -55,12 +54,11 @@ class MaterialSlice extends MergeableMaterialItem { ...@@ -55,12 +54,11 @@ class MaterialSlice extends MergeableMaterialItem {
/// All [MaterialGap] objects need a [LocalKey]. /// All [MaterialGap] objects need a [LocalKey].
class MaterialGap extends MergeableMaterialItem { class MaterialGap extends MergeableMaterialItem {
/// Creates a Material gap with a given size. /// Creates a Material gap with a given size.
MaterialGap({ const MaterialGap({
@required LocalKey key, @required LocalKey key,
this.size: 16.0 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] /// The main axis extent of this gap. For example, if the [MergableMaterial]
/// is vertical, then this is the height of the gap. /// is vertical, then this is the height of the gap.
......
...@@ -475,7 +475,7 @@ class PopupMenuButton<T> extends StatefulWidget { ...@@ -475,7 +475,7 @@ class PopupMenuButton<T> extends StatefulWidget {
/// Creates a button that shows a popup menu. /// Creates a button that shows a popup menu.
/// ///
/// The [itemBuilder] argument must not be null. /// The [itemBuilder] argument must not be null.
PopupMenuButton({ const PopupMenuButton({
Key key, Key key,
@required this.itemBuilder, @required this.itemBuilder,
this.initialValue, this.initialValue,
...@@ -484,9 +484,8 @@ class PopupMenuButton<T> extends StatefulWidget { ...@@ -484,9 +484,8 @@ class PopupMenuButton<T> extends StatefulWidget {
this.elevation: 8, this.elevation: 8,
this.padding: const EdgeInsets.all(8.0), this.padding: const EdgeInsets.all(8.0),
this.child 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. /// Called when the button is pressed to create the items to show in the menu.
final PopupMenuItemBuilder<T> itemBuilder; final PopupMenuItemBuilder<T> itemBuilder;
......
...@@ -127,19 +127,18 @@ class _RadioState<T> extends State<Radio<T>> with TickerProviderStateMixin { ...@@ -127,19 +127,18 @@ class _RadioState<T> extends State<Radio<T>> with TickerProviderStateMixin {
} }
class _RadioRenderObjectWidget extends LeafRenderObjectWidget { class _RadioRenderObjectWidget extends LeafRenderObjectWidget {
_RadioRenderObjectWidget({ const _RadioRenderObjectWidget({
Key key, Key key,
@required this.selected, @required this.selected,
@required this.activeColor, @required this.activeColor,
@required this.inactiveColor, @required this.inactiveColor,
this.onChanged, this.onChanged,
@required this.vsync, @required this.vsync,
}) : super(key: key) { }) : assert(selected != null),
assert(selected != null); assert(activeColor != null),
assert(activeColor != null); assert(inactiveColor != null),
assert(inactiveColor != null); assert(vsync != null),
assert(vsync != null); super(key: key);
}
final bool selected; final bool selected;
final Color inactiveColor; final Color inactiveColor;
......
...@@ -80,17 +80,16 @@ class RefreshIndicator extends StatefulWidget { ...@@ -80,17 +80,16 @@ class RefreshIndicator extends StatefulWidget {
/// ///
/// The [onRefresh] and [child] arguments must be non-null. The default /// The [onRefresh] and [child] arguments must be non-null. The default
/// [displacement] is 40.0 logical pixels. /// [displacement] is 40.0 logical pixels.
RefreshIndicator({ const RefreshIndicator({
Key key, Key key,
@required this.child, @required this.child,
this.displacement: 40.0, this.displacement: 40.0,
@required this.onRefresh, @required this.onRefresh,
this.color, this.color,
this.backgroundColor this.backgroundColor
}) : super(key: key) { }) : assert(child != null),
assert(child != null); assert(onRefresh != null),
assert(onRefresh != null); super(key: key);
}
/// The refresh indicator will be stacked on top of this child. The indicator /// The refresh indicator will be stacked on top of this child. The indicator
/// will appear when child's Scrollable descendant is over-scrolled. /// will appear when child's Scrollable descendant is over-scrolled.
......
...@@ -1015,12 +1015,11 @@ class PersistentBottomSheetController<T> extends ScaffoldFeatureController<_Pers ...@@ -1015,12 +1015,11 @@ class PersistentBottomSheetController<T> extends ScaffoldFeatureController<_Pers
} }
class _ScaffoldScope extends InheritedWidget { class _ScaffoldScope extends InheritedWidget {
_ScaffoldScope({ const _ScaffoldScope({
@required this.hasDrawer, @required this.hasDrawer,
@required Widget child, @required Widget child,
}) : super(child: child) { }) : assert(hasDrawer != null),
assert(hasDrawer != null); super(child: child);
}
final bool hasDrawer; final bool hasDrawer;
......
...@@ -49,7 +49,7 @@ class Slider extends StatefulWidget { ...@@ -49,7 +49,7 @@ class Slider extends StatefulWidget {
/// ///
/// * [value] determines currently selected value for this slider. /// * [value] determines currently selected value for this slider.
/// * [onChanged] is called when the user selects a new value for the slider. /// * [onChanged] is called when the user selects a new value for the slider.
Slider({ const Slider({
Key key, Key key,
@required this.value, @required this.value,
@required this.onChanged, @required this.onChanged,
...@@ -59,14 +59,13 @@ class Slider extends StatefulWidget { ...@@ -59,14 +59,13 @@ class Slider extends StatefulWidget {
this.label, this.label,
this.activeColor, this.activeColor,
this.thumbOpenAtMin: false, this.thumbOpenAtMin: false,
}) : super(key: key) { }) : assert(value != null),
assert(value != null); assert(min != null),
assert(min != null); assert(max != null),
assert(max != null); assert(value >= min && value <= max),
assert(value >= min && value <= max); assert(divisions == null || divisions > 0),
assert(divisions == null || divisions > 0); assert(thumbOpenAtMin != null),
assert(thumbOpenAtMin != null); super(key: key);
}
/// The currently selected value for this slider. /// The currently selected value for this slider.
/// ///
......
...@@ -79,14 +79,13 @@ class SnackBarAction extends StatefulWidget { ...@@ -79,14 +79,13 @@ class SnackBarAction extends StatefulWidget {
/// Creates an action for a [SnackBar]. /// Creates an action for a [SnackBar].
/// ///
/// The [label] and [onPressed] arguments must be non-null. /// The [label] and [onPressed] arguments must be non-null.
SnackBarAction({ const SnackBarAction({
Key key, Key key,
@required this.label, @required this.label,
@required this.onPressed @required this.onPressed
}) : super(key: key) { }) : assert(label != null),
assert(label != null); assert(onPressed != null),
assert(onPressed != null); super(key: key);
}
/// The button label. /// The button label.
final String label; final String label;
...@@ -145,16 +144,15 @@ class SnackBar extends StatelessWidget { ...@@ -145,16 +144,15 @@ class SnackBar extends StatelessWidget {
/// Creates a snack bar. /// Creates a snack bar.
/// ///
/// The [content] argument must be non-null. /// The [content] argument must be non-null.
SnackBar({ const SnackBar({
Key key, Key key,
@required this.content, @required this.content,
this.backgroundColor, this.backgroundColor,
this.action, this.action,
this.duration: _kSnackBarDisplayDuration, this.duration: _kSnackBarDisplayDuration,
this.animation, this.animation,
}) : super(key: key) { }) : assert(content != null),
assert(content != null); super(key: key);
}
/// The primary content of the snack bar. /// The primary content of the snack bar.
/// ///
......
...@@ -80,17 +80,15 @@ class Step { ...@@ -80,17 +80,15 @@ class Step {
/// Creates a step for a [Stepper]. /// Creates a step for a [Stepper].
/// ///
/// The [title], [content], and [state] arguments must not be null. /// The [title], [content], and [state] arguments must not be null.
Step({ const Step({
@required this.title, @required this.title,
this.subtitle, this.subtitle,
@required this.content, @required this.content,
this.state: StepState.indexed, this.state: StepState.indexed,
this.isActive: false, this.isActive: false,
}) { }) : assert(title != null),
assert(title != null); assert(content != null),
assert(content != null); assert(state != null);
assert(state != null);
}
/// The title of the step that typically describes it. /// The title of the step that typically describes it.
final Widget title; final Widget title;
......
...@@ -39,13 +39,12 @@ const EdgeInsets _kTabLabelPadding = const EdgeInsets.symmetric(horizontal: 12.0 ...@@ -39,13 +39,12 @@ const EdgeInsets _kTabLabelPadding = const EdgeInsets.symmetric(horizontal: 12.0
class Tab extends StatelessWidget { class Tab extends StatelessWidget {
/// Creates a material design [TabBar] tab. At least one of [text] and [icon] /// Creates a material design [TabBar] tab. At least one of [text] and [icon]
/// must be non-null. /// must be non-null.
Tab({ const Tab({
Key key, Key key,
this.text, this.text,
this.icon, 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. /// The text to display as the tab's label.
final String text; final String text;
......
...@@ -31,15 +31,14 @@ class Theme extends InheritedWidget { ...@@ -31,15 +31,14 @@ class Theme extends InheritedWidget {
/// Applies the given theme [data] to [child]. /// Applies the given theme [data] to [child].
/// ///
/// The [data] and [child] arguments must not be null. /// The [data] and [child] arguments must not be null.
Theme({ const Theme({
Key key, Key key,
@required this.data, @required this.data,
this.isMaterialAppTheme: false, this.isMaterialAppTheme: false,
@required Widget child @required Widget child
}) : super(key: key, child: child) { }) : assert(child != null),
assert(child != null); assert(data != null),
assert(data != null); super(key: key, child: child);
}
/// Specifies the color and typography values for descendant widgets. /// Specifies the color and typography values for descendant widgets.
final ThemeData data; final ThemeData data;
...@@ -154,17 +153,16 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget { ...@@ -154,17 +153,16 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget {
/// ///
/// By default, the theme transition uses a linear curve. The [data] and /// By default, the theme transition uses a linear curve. The [data] and
/// [child] arguments must not be null. /// [child] arguments must not be null.
AnimatedTheme({ const AnimatedTheme({
Key key, Key key,
@required this.data, @required this.data,
this.isMaterialAppTheme: false, this.isMaterialAppTheme: false,
Curve curve: Curves.linear, Curve curve: Curves.linear,
Duration duration: kThemeAnimationDuration, Duration duration: kThemeAnimationDuration,
@required this.child, @required this.child,
}) : super(key: key, curve: curve, duration: duration) { }) : assert(child != null),
assert(child != null); assert(data != null),
assert(data != null); super(key: key, curve: curve, duration: duration);
}
/// Specifies the color and typography values for descendant widgets. /// Specifies the color and typography values for descendant widgets.
final ThemeData data; final ThemeData data;
......
...@@ -184,7 +184,7 @@ class ThemeData { ...@@ -184,7 +184,7 @@ class ThemeData {
/// This will rarely be used directly. It is used by [lerp] to /// This will rarely be used directly. It is used by [lerp] to
/// create intermediate themes based on two themes created with the /// create intermediate themes based on two themes created with the
/// [new ThemeData] constructor. /// [new ThemeData] constructor.
ThemeData.raw({ const ThemeData.raw({
@required this.brightness, @required this.brightness,
@required this.primaryColor, @required this.primaryColor,
@required this.primaryColorBrightness, @required this.primaryColorBrightness,
...@@ -215,38 +215,36 @@ class ThemeData { ...@@ -215,38 +215,36 @@ class ThemeData {
@required this.primaryIconTheme, @required this.primaryIconTheme,
@required this.accentIconTheme, @required this.accentIconTheme,
@required this.platform @required this.platform
}) { }) : assert(brightness != null),
assert(brightness != null); assert(primaryColor != null),
assert(primaryColor != null); assert(primaryColorBrightness != null),
assert(primaryColorBrightness != null); assert(accentColor != null),
assert(accentColor != null); assert(accentColorBrightness != null),
assert(accentColorBrightness != null); assert(canvasColor != null),
assert(canvasColor != null); assert(scaffoldBackgroundColor != null),
assert(scaffoldBackgroundColor != null); assert(cardColor != null),
assert(cardColor != null); assert(dividerColor != null),
assert(dividerColor != null); assert(highlightColor != null),
assert(highlightColor != null); assert(splashColor != null),
assert(splashColor != null); assert(selectedRowColor != null),
assert(selectedRowColor != null); assert(unselectedWidgetColor != null),
assert(unselectedWidgetColor != null); assert(disabledColor != null),
assert(disabledColor != null); assert(buttonColor != null),
assert(buttonColor != null); assert(secondaryHeaderColor != null),
assert(secondaryHeaderColor != null); assert(textSelectionColor != null),
assert(textSelectionColor != null); assert(textSelectionHandleColor != null),
assert(textSelectionHandleColor != null); assert(backgroundColor != null),
assert(backgroundColor != null); assert(dialogBackgroundColor != null),
assert(dialogBackgroundColor != null); assert(indicatorColor != null),
assert(indicatorColor != null); assert(hintColor != null),
assert(hintColor != null); assert(errorColor != null),
assert(errorColor != null); assert(textTheme != null),
assert(textTheme != null); assert(primaryTextTheme != null),
assert(primaryTextTheme != null); assert(accentTextTheme != null),
assert(accentTextTheme != null); assert(iconTheme != null),
assert(iconTheme != null); assert(primaryIconTheme != null),
assert(primaryIconTheme != null); assert(accentIconTheme != null),
assert(accentIconTheme != null); assert(platform != null);
assert(platform != null);
}
/// A default light blue theme. /// A default light blue theme.
factory ThemeData.light() => new ThemeData(brightness: Brightness.light); factory ThemeData.light() => new ThemeData(brightness: Brightness.light);
......
...@@ -207,17 +207,15 @@ class _TimePickerHeaderLayout extends MultiChildLayoutDelegate { ...@@ -207,17 +207,15 @@ class _TimePickerHeaderLayout extends MultiChildLayoutDelegate {
// TODO(ianh): Localize! // TODO(ianh): Localize!
class _TimePickerHeader extends StatelessWidget { class _TimePickerHeader extends StatelessWidget {
_TimePickerHeader({ const _TimePickerHeader({
@required this.selectedTime, @required this.selectedTime,
@required this.mode, @required this.mode,
@required this.orientation, @required this.orientation,
@required this.onModeChanged, @required this.onModeChanged,
@required this.onChanged, @required this.onChanged,
}) { }) : assert(selectedTime != null),
assert(selectedTime != null); assert(mode != null),
assert(mode != null); assert(orientation != null);
assert(orientation != null);
}
final TimeOfDay selectedTime; final TimeOfDay selectedTime;
final _TimePickerMode mode; final _TimePickerMode mode;
...@@ -447,13 +445,11 @@ class _DialPainter extends CustomPainter { ...@@ -447,13 +445,11 @@ class _DialPainter extends CustomPainter {
} }
class _Dial extends StatefulWidget { class _Dial extends StatefulWidget {
_Dial({ const _Dial({
@required this.selectedTime, @required this.selectedTime,
@required this.mode, @required this.mode,
@required this.onChanged @required this.onChanged
}) { }) : assert(selectedTime != null);
assert(selectedTime != null);
}
final TimeOfDay selectedTime; final TimeOfDay selectedTime;
final _TimePickerMode mode; final _TimePickerMode mode;
...@@ -625,12 +621,11 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { ...@@ -625,12 +621,11 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
} }
class _TimePickerDialog extends StatefulWidget { class _TimePickerDialog extends StatefulWidget {
_TimePickerDialog({ const _TimePickerDialog({
Key key, Key key,
@required this.initialTime @required this.initialTime
}) : super(key: key) { }) : assert(initialTime != null),
assert(initialTime != null); super(key: key);
}
final TimeOfDay initialTime; final TimeOfDay initialTime;
......
...@@ -41,7 +41,7 @@ class Tooltip extends StatefulWidget { ...@@ -41,7 +41,7 @@ class Tooltip extends StatefulWidget {
/// user long presses on the widget. /// user long presses on the widget.
/// ///
/// The [message] argument cannot be null. /// The [message] argument cannot be null.
Tooltip({ const Tooltip({
Key key, Key key,
@required this.message, @required this.message,
this.height: 32.0, this.height: 32.0,
...@@ -49,14 +49,13 @@ class Tooltip extends StatefulWidget { ...@@ -49,14 +49,13 @@ class Tooltip extends StatefulWidget {
this.verticalOffset: 24.0, this.verticalOffset: 24.0,
this.preferBelow: true, this.preferBelow: true,
@required this.child, @required this.child,
}) : super(key: key) { }) : assert(message != null),
assert(message != null); assert(height != null),
assert(height != null); assert(padding != null),
assert(padding != null); assert(verticalOffset != null),
assert(verticalOffset != null); assert(preferBelow != null),
assert(preferBelow != null); assert(child != null),
assert(child != null); super(key: key);
}
/// The text to display in the tooltip. /// The text to display in the tooltip.
final String message; final String message;
......
...@@ -29,7 +29,7 @@ const Duration _kExpand = const Duration(milliseconds: 200); ...@@ -29,7 +29,7 @@ const Duration _kExpand = const Duration(milliseconds: 200);
/// * [ListTile] /// * [ListTile]
class TwoLevelListItem extends StatelessWidget { class TwoLevelListItem extends StatelessWidget {
/// Creates an item in a two-level list. /// Creates an item in a two-level list.
TwoLevelListItem({ const TwoLevelListItem({
Key key, Key key,
this.leading, this.leading,
@required this.title, @required this.title,
...@@ -37,9 +37,8 @@ class TwoLevelListItem extends StatelessWidget { ...@@ -37,9 +37,8 @@ class TwoLevelListItem extends StatelessWidget {
this.enabled: true, this.enabled: true,
this.onTap, this.onTap,
this.onLongPress this.onLongPress
}) : super(key: key) { }) : assert(title != null),
assert(title != null); super(key: key);
}
/// A widget to display before the title. /// A widget to display before the title.
/// ///
...@@ -259,14 +258,13 @@ class TwoLevelList extends StatelessWidget { ...@@ -259,14 +258,13 @@ class TwoLevelList extends StatelessWidget {
/// Creates a scrollable list of items that can expand and collapse. /// Creates a scrollable list of items that can expand and collapse.
/// ///
/// The [type] argument must not be null. /// The [type] argument must not be null.
TwoLevelList({ const TwoLevelList({
Key key, Key key,
this.children: const <Widget>[], this.children: const <Widget>[],
this.type: MaterialListType.twoLine, this.type: MaterialListType.twoLine,
this.padding this.padding
}) : super(key: key) { }) : assert(type != null),
assert(type != null); super(key: key);
}
/// The widgets to display in this list. /// The widgets to display in this list.
/// ///
......
...@@ -32,9 +32,8 @@ class TextSelectionPoint { ...@@ -32,9 +32,8 @@ class TextSelectionPoint {
/// Creates a description of a point in a text selection. /// Creates a description of a point in a text selection.
/// ///
/// The [point] argument must not be null. /// The [point] argument must not be null.
TextSelectionPoint(this.point, this.direction) { const TextSelectionPoint(this.point, this.direction)
assert(point != null); : assert(point != null);
}
/// Screen coordinates of the lower left or lower right corner of the selection. /// Screen coordinates of the lower left or lower right corner of the selection.
final Offset point; final Offset point;
......
...@@ -60,18 +60,16 @@ class SemanticsData { ...@@ -60,18 +60,16 @@ class SemanticsData {
/// Creates a semantics data object. /// Creates a semantics data object.
/// ///
/// The [flags], [actions], [label], and [Rect] arguments must not be null. /// The [flags], [actions], [label], and [Rect] arguments must not be null.
SemanticsData({ const SemanticsData({
@required this.flags, @required this.flags,
@required this.actions, @required this.actions,
@required this.label, @required this.label,
@required this.rect, @required this.rect,
this.transform this.transform
}) { }) : assert(flags != null),
assert(flags != null); assert(actions != null),
assert(actions != null); assert(label != null),
assert(label != null); assert(rect != null);
assert(rect != null);
}
/// A bit field of [SemanticsFlags] that apply to this node. /// A bit field of [SemanticsFlags] that apply to this node.
final int flags; final int flags;
......
...@@ -44,7 +44,7 @@ class AnimatedCrossFade extends StatefulWidget { ...@@ -44,7 +44,7 @@ class AnimatedCrossFade extends StatefulWidget {
/// The [duration] of the animation is the same for all components (fade in, /// 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 /// 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. /// order to have finer control, e.g., creating an overlap between the fades.
AnimatedCrossFade({ const AnimatedCrossFade({
Key key, Key key,
@required this.firstChild, @required this.firstChild,
@required this.secondChild, @required this.secondChild,
...@@ -53,11 +53,10 @@ class AnimatedCrossFade extends StatefulWidget { ...@@ -53,11 +53,10 @@ class AnimatedCrossFade extends StatefulWidget {
this.sizeCurve: Curves.linear, this.sizeCurve: Curves.linear,
@required this.crossFadeState, @required this.crossFadeState,
@required this.duration @required this.duration
}) : super(key: key) { }) : assert(firstCurve != null),
assert(firstCurve != null); assert(secondCurve != null),
assert(secondCurve != null); assert(sizeCurve != null),
assert(sizeCurve != null); super(key: key);
}
/// The child that is visible when [crossFadeState] is [showFirst]. It fades /// The child that is visible when [crossFadeState] is [showFirst]. It fades
/// out when transitioning from [showFirst] to [showSecond] and vice versa. /// out when transitioning from [showFirst] to [showSecond] and vice versa.
......
...@@ -38,7 +38,7 @@ typedef Future<LocaleQueryData> LocaleChangedCallback(Locale locale); ...@@ -38,7 +38,7 @@ typedef Future<LocaleQueryData> LocaleChangedCallback(Locale locale);
class WidgetsApp extends StatefulWidget { class WidgetsApp extends StatefulWidget {
/// Creates a widget that wraps a number of widgets that are commonly /// Creates a widget that wraps a number of widgets that are commonly
/// required for an application. /// required for an application.
WidgetsApp({ const WidgetsApp({
Key key, Key key,
@required this.onGenerateRoute, @required this.onGenerateRoute,
this.title, this.title,
...@@ -51,13 +51,12 @@ class WidgetsApp extends StatefulWidget { ...@@ -51,13 +51,12 @@ class WidgetsApp extends StatefulWidget {
this.checkerboardRasterCacheImages: false, this.checkerboardRasterCacheImages: false,
this.showSemanticsDebugger: false, this.showSemanticsDebugger: false,
this.debugShowCheckedModeBanner: true this.debugShowCheckedModeBanner: true
}) : super(key: key) { }) : assert(color != null),
assert(color != null); assert(onGenerateRoute != null),
assert(onGenerateRoute != null); assert(showPerformanceOverlay != null),
assert(showPerformanceOverlay != null); assert(checkerboardRasterCacheImages != null),
assert(checkerboardRasterCacheImages != null); assert(showSemanticsDebugger != null),
assert(showSemanticsDebugger != null); super(key: key);
}
/// A one-line description of this app for use in the window manager. /// A one-line description of this app for use in the window manager.
final String title; final String title;
......
...@@ -187,19 +187,18 @@ enum ConnectionState { ...@@ -187,19 +187,18 @@ enum ConnectionState {
class AsyncSnapshot<T> { class AsyncSnapshot<T> {
/// Creates an [AsyncSnapshot] with the specified [connectionState], /// Creates an [AsyncSnapshot] with the specified [connectionState],
/// and optionally either [data] or [error] (but not both). /// and optionally either [data] or [error] (but not both).
AsyncSnapshot._(this.connectionState, this.data, this.error) { const AsyncSnapshot._(this.connectionState, this.data, this.error)
assert(connectionState != null); : assert(connectionState != null),
assert(data == null || error == null); assert(!(data != null && error != null));
}
/// Creates an [AsyncSnapshot] in [ConnectionState.none] with null data and error. /// 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]. /// 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]. /// 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. /// Current state of connection to the asynchronous computation.
final ConnectionState connectionState; final ConnectionState connectionState;
...@@ -309,19 +308,18 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> { ...@@ -309,19 +308,18 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// Creates a new [StreamBuilder] that builds itself based on the latest /// Creates a new [StreamBuilder] that builds itself based on the latest
/// snapshot of interaction with the specified [stream] and whose build /// snapshot of interaction with the specified [stream] and whose build
/// strategy is given by [builder]. /// strategy is given by [builder].
StreamBuilder({ const StreamBuilder({
Key key, Key key,
Stream<T> stream, Stream<T> stream,
@required this.builder @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. /// The build strategy currently used by this builder. Cannot be null.
final AsyncWidgetBuilder<T> builder; final AsyncWidgetBuilder<T> builder;
@override @override
AsyncSnapshot<T> initial() => new AsyncSnapshot<T>.nothing(); AsyncSnapshot<T> initial() => new AsyncSnapshot<T>.nothing(); // ignore: prefer_const_constructors
@override @override
AsyncSnapshot<T> afterConnected(AsyncSnapshot<T> current) => current.inState(ConnectionState.waiting); AsyncSnapshot<T> afterConnected(AsyncSnapshot<T> current) => current.inState(ConnectionState.waiting);
...@@ -387,13 +385,12 @@ class FutureBuilder<T> extends StatefulWidget { ...@@ -387,13 +385,12 @@ class FutureBuilder<T> extends StatefulWidget {
/// interaction with a [Future]. /// interaction with a [Future].
/// ///
/// The [builder] must not be null. /// The [builder] must not be null.
FutureBuilder({ const FutureBuilder({
Key key, Key key,
this.future, this.future,
@required this.builder @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, /// The asynchronous computation to which this builder is currently connected,
/// possibly null. /// possibly null.
...@@ -412,7 +409,7 @@ class _FutureBuilderState<T> extends State<FutureBuilder<T>> { ...@@ -412,7 +409,7 @@ class _FutureBuilderState<T> extends State<FutureBuilder<T>> {
/// calling setState from stale callbacks, e.g. after disposal of this state, /// calling setState from stale callbacks, e.g. after disposal of this state,
/// or after widget reconfiguration to a new Future. /// or after widget reconfiguration to a new Future.
Object _activeCallbackIdentity; Object _activeCallbackIdentity;
AsyncSnapshot<T> _snapshot = new AsyncSnapshot<T>.nothing(); AsyncSnapshot<T> _snapshot = new AsyncSnapshot<T>.nothing(); // ignore: prefer_const_constructors
@override @override
void initState() { void initState() {
......
...@@ -71,7 +71,7 @@ class Dismissible extends StatefulWidget { ...@@ -71,7 +71,7 @@ class Dismissible extends StatefulWidget {
/// which means the item after the dismissed item would be synced with the /// 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 /// state of the dismissed item. Using keys causes the widgets to sync
/// according to their keys and avoids this pitfall. /// according to their keys and avoids this pitfall.
Dismissible({ const Dismissible({
@required Key key, @required Key key,
@required this.child, @required this.child,
this.background, this.background,
...@@ -81,10 +81,9 @@ class Dismissible extends StatefulWidget { ...@@ -81,10 +81,9 @@ class Dismissible extends StatefulWidget {
this.direction: DismissDirection.horizontal, this.direction: DismissDirection.horizontal,
this.resizeDuration: const Duration(milliseconds: 300), this.resizeDuration: const Duration(milliseconds: 300),
this.dismissThresholds: const <DismissDirection, double>{}, this.dismissThresholds: const <DismissDirection, double>{},
}) : super(key: key) { }) : assert(key != null),
assert(key != null); assert(secondaryBackground != null ? background != null : true),
assert(secondaryBackground != null ? background != null : true); super(key: key);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
......
...@@ -117,7 +117,7 @@ class EditableText extends StatefulWidget { ...@@ -117,7 +117,7 @@ class EditableText extends StatefulWidget {
/// ///
/// The [controller], [focusNode], [style], and [cursorColor] arguments must /// The [controller], [focusNode], [style], and [cursorColor] arguments must
/// not be null. /// not be null.
EditableText({ const EditableText({
Key key, Key key,
@required this.controller, @required this.controller,
@required this.focusNode, @required this.focusNode,
...@@ -133,15 +133,14 @@ class EditableText extends StatefulWidget { ...@@ -133,15 +133,14 @@ class EditableText extends StatefulWidget {
this.keyboardType, this.keyboardType,
this.onChanged, this.onChanged,
this.onSubmitted, this.onSubmitted,
}) : super(key: key) { }) : assert(controller != null),
assert(controller != null); assert(focusNode != null),
assert(focusNode != null); assert(obscureText != null),
assert(obscureText != null); assert(style != null),
assert(style != null); assert(cursorColor != null),
assert(cursorColor != null); assert(maxLines != null),
assert(maxLines != null); assert(autofocus != null),
assert(autofocus != null); super(key: key);
}
/// Controls the text being edited. /// Controls the text being edited.
final TextEditingController controller; final TextEditingController controller;
......
...@@ -10,13 +10,12 @@ import 'focus_manager.dart'; ...@@ -10,13 +10,12 @@ import 'focus_manager.dart';
import 'framework.dart'; import 'framework.dart';
class _FocusScopeMarker extends InheritedWidget { class _FocusScopeMarker extends InheritedWidget {
_FocusScopeMarker({ const _FocusScopeMarker({
Key key, Key key,
@required this.node, @required this.node,
Widget child, Widget child,
}) : super(key: key, child: child) { }) : assert(node != null),
assert(node != null); super(key: key, child: child);
}
final FocusScopeNode node; final FocusScopeNode node;
...@@ -53,15 +52,14 @@ class FocusScope extends StatefulWidget { ...@@ -53,15 +52,14 @@ class FocusScope extends StatefulWidget {
/// Creates a scope in which widgets can receive focus. /// Creates a scope in which widgets can receive focus.
/// ///
/// The [node] argument must not be null. /// The [node] argument must not be null.
FocusScope({ const FocusScope({
Key key, Key key,
@required this.node, @required this.node,
this.autofocus: false, this.autofocus: false,
this.child, this.child,
}) : super(key: key) { }) : assert(node != null),
assert(node != null); assert(autofocus != null),
assert(autofocus != null); super(key: key);
}
/// Controls whether this scope is currently active. /// Controls whether this scope is currently active.
final FocusScopeNode node; final FocusScopeNode node;
......
...@@ -21,14 +21,13 @@ class Form extends StatefulWidget { ...@@ -21,14 +21,13 @@ class Form extends StatefulWidget {
/// Creates a container for form fields. /// Creates a container for form fields.
/// ///
/// The [child] argument must not be null. /// The [child] argument must not be null.
Form({ const Form({
Key key, Key key,
@required this.child, @required this.child,
this.autovalidate: false, this.autovalidate: false,
this.onWillPop, this.onWillPop,
}) : super(key: key) { }) : assert(child != null),
assert(child != null); super(key: key);
}
/// Returns the closest [FormState] which encloses the given context. /// Returns the closest [FormState] which encloses the given context.
/// ///
...@@ -194,16 +193,15 @@ class FormField<T> extends StatefulWidget { ...@@ -194,16 +193,15 @@ class FormField<T> extends StatefulWidget {
/// Creates a single form field. /// Creates a single form field.
/// ///
/// The [builder] argument must not be null. /// The [builder] argument must not be null.
FormField({ const FormField({
Key key, Key key,
@required this.builder, @required this.builder,
this.onSaved, this.onSaved,
this.validator, this.validator,
this.initialValue, this.initialValue,
this.autovalidate: false, 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 /// An optional method to call with the final value when the form is saved via
/// Form.save(). /// Form.save().
......
...@@ -325,16 +325,15 @@ class RawGestureDetector extends StatefulWidget { ...@@ -325,16 +325,15 @@ class RawGestureDetector extends StatefulWidget {
/// ///
/// By default, gesture detectors contribute semantic information to the tree /// By default, gesture detectors contribute semantic information to the tree
/// that is used by assistive technology. /// that is used by assistive technology.
RawGestureDetector({ const RawGestureDetector({
Key key, Key key,
this.child, this.child,
this.gestures: const <Type, GestureRecognizerFactory>{}, this.gestures: const <Type, GestureRecognizerFactory>{},
this.behavior, this.behavior,
this.excludeFromSemantics: false this.excludeFromSemantics: false
}) : super(key: key) { }) : assert(gestures != null),
assert(gestures != null); assert(excludeFromSemantics != null),
assert(excludeFromSemantics != null); super(key: key);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
......
...@@ -77,14 +77,13 @@ class Hero extends StatefulWidget { ...@@ -77,14 +77,13 @@ class Hero extends StatefulWidget {
/// Create a hero. /// Create a hero.
/// ///
/// The [tag] and [child] parameters must not be null. /// The [tag] and [child] parameters must not be null.
Hero({ const Hero({
Key key, Key key,
@required this.tag, @required this.tag,
@required this.child, @required this.child,
}) : super(key: key) { }) : assert(tag != null),
assert(tag != null); assert(child != null),
assert(child != null); super(key: key);
}
/// The identifier for this particular hero. If the tag of this hero matches /// 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 /// the tag of a hero on a [PageRoute] that we're navigating to or from, then
......
...@@ -63,7 +63,7 @@ class Image extends StatefulWidget { ...@@ -63,7 +63,7 @@ class Image extends StatefulWidget {
/// [new Image.network] and [new Image.asset] respectively. /// [new Image.network] and [new Image.asset] respectively.
/// ///
/// The [image] and [repeat] arguments must not be null. /// The [image] and [repeat] arguments must not be null.
Image({ const Image({
Key key, Key key,
@required this.image, @required this.image,
this.width, this.width,
...@@ -75,9 +75,8 @@ class Image extends StatefulWidget { ...@@ -75,9 +75,8 @@ class Image extends StatefulWidget {
this.repeat: ImageRepeat.noRepeat, this.repeat: ImageRepeat.noRepeat,
this.centerSlice, this.centerSlice,
this.gaplessPlayback: false 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. /// Creates a widget that displays an [ImageStream] obtained from the network.
/// ///
......
...@@ -88,14 +88,13 @@ abstract class ImplicitlyAnimatedWidget extends StatefulWidget { ...@@ -88,14 +88,13 @@ abstract class ImplicitlyAnimatedWidget extends StatefulWidget {
/// Initializes fields for subclasses. /// Initializes fields for subclasses.
/// ///
/// The [curve] and [duration] arguments must not be null. /// The [curve] and [duration] arguments must not be null.
ImplicitlyAnimatedWidget({ const ImplicitlyAnimatedWidget({
Key key, Key key,
this.curve: Curves.linear, this.curve: Curves.linear,
@required this.duration @required this.duration
}) : super(key: key) { }) : assert(curve != null),
assert(curve != null); assert(duration != null),
assert(duration != null); super(key: key);
}
/// The curve to apply when animating the parameters of this container. /// The curve to apply when animating the parameters of this container.
final Curve curve; final Curve curve;
...@@ -386,7 +385,7 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget { ...@@ -386,7 +385,7 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget {
/// the three must be null. /// the three must be null.
/// ///
/// The [curve] and [duration] arguments must not be null. /// The [curve] and [duration] arguments must not be null.
AnimatedPositioned({ const AnimatedPositioned({
Key key, Key key,
@required this.child, @required this.child,
this.left, this.left,
...@@ -397,10 +396,9 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget { ...@@ -397,10 +396,9 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget {
this.height, this.height,
Curve curve: Curves.linear, Curve curve: Curves.linear,
@required Duration duration, @required Duration duration,
}) : super(key: key, curve: curve, duration: duration) { }) : assert(left == null || right == null || width == null),
assert(left == null || right == null || width == null); assert(top == null || bottom == null || height == 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. /// Creates a widget that animates the rectangle it occupies implicitly.
/// ///
...@@ -526,15 +524,14 @@ class AnimatedOpacity extends ImplicitlyAnimatedWidget { ...@@ -526,15 +524,14 @@ class AnimatedOpacity extends ImplicitlyAnimatedWidget {
/// ///
/// The [opacity] argument must not be null and must be between 0.0 and 1.0, /// 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. /// inclusive. The [curve] and [duration] arguments must not be null.
AnimatedOpacity({ const AnimatedOpacity({
Key key, Key key,
this.child, this.child,
@required this.opacity, @required this.opacity,
Curve curve: Curves.linear, Curve curve: Curves.linear,
@required Duration duration, @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. /// The widget below this widget in the tree.
final Widget child; final Widget child;
...@@ -583,16 +580,15 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget { ...@@ -583,16 +580,15 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget {
/// Creates a widget that animates the default text style implicitly. /// Creates a widget that animates the default text style implicitly.
/// ///
/// The [child], [style], [curve], and [duration] arguments must not be null. /// The [child], [style], [curve], and [duration] arguments must not be null.
AnimatedDefaultTextStyle({ const AnimatedDefaultTextStyle({
Key key, Key key,
@required this.child, @required this.child,
@required this.style, @required this.style,
Curve curve: Curves.linear, Curve curve: Curves.linear,
@required Duration duration, @required Duration duration,
}) : super(key: key, curve: curve, duration: duration) { }) : assert(style != null),
assert(style != null); assert(child != null),
assert(child != null); super(key: key, curve: curve, duration: duration);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
......
...@@ -32,12 +32,11 @@ class LayoutBuilder extends RenderObjectWidget { ...@@ -32,12 +32,11 @@ class LayoutBuilder extends RenderObjectWidget {
/// Creates a widget that defers its building until layout. /// Creates a widget that defers its building until layout.
/// ///
/// The [builder] argument must not be null. /// The [builder] argument must not be null.
LayoutBuilder({ const LayoutBuilder({
Key key, Key key,
@required this.builder @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 /// Called at layout time to construct the widget tree. The builder must not
/// return null. /// return null.
......
...@@ -12,13 +12,12 @@ class LocaleQueryData { } // TODO(ianh): We need a better type here. This doesn' ...@@ -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. /// Establishes a subtree in which locale queries resolve to the given data.
class LocaleQuery extends InheritedWidget { class LocaleQuery extends InheritedWidget {
/// Creates a widget that provides [LocaleQueryData] to its descendants. /// Creates a widget that provides [LocaleQueryData] to its descendants.
LocaleQuery({ const LocaleQuery({
Key key, Key key,
@required this.data, @required this.data,
@required Widget child @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. /// The locale data for this subtree.
final LocaleQueryData data; final LocaleQueryData data;
......
...@@ -121,14 +121,13 @@ class MediaQuery extends InheritedWidget { ...@@ -121,14 +121,13 @@ class MediaQuery extends InheritedWidget {
/// Creates a widget that provides [MediaQueryData] to its descendants. /// Creates a widget that provides [MediaQueryData] to its descendants.
/// ///
/// The [data] and [child] arguments must not be null. /// The [data] and [child] arguments must not be null.
MediaQuery({ const MediaQuery({
Key key, Key key,
@required this.data, @required this.data,
@required Widget child, @required Widget child,
}) : super(key: key, child: child) { }) : assert(child != null),
assert(child != null); assert(data != null),
assert(data != null); super(key: key, child: child);
}
/// Contains information about the current media. /// Contains information about the current media.
/// ///
......
...@@ -475,15 +475,14 @@ class Navigator extends StatefulWidget { ...@@ -475,15 +475,14 @@ class Navigator extends StatefulWidget {
/// Creates a widget that maintains a stack-based history of child widgets. /// Creates a widget that maintains a stack-based history of child widgets.
/// ///
/// The [onGenerateRoute] argument must not be null. /// The [onGenerateRoute] argument must not be null.
Navigator({ const Navigator({
Key key, Key key,
this.initialRoute, this.initialRoute,
@required this.onGenerateRoute, @required this.onGenerateRoute,
this.onUnknownRoute, this.onUnknownRoute,
this.observers: const <NavigatorObserver>[] this.observers: const <NavigatorObserver>[]
}) : super(key: key) { }) : assert(onGenerateRoute != null),
assert(onGenerateRoute != null); super(key: key);
}
/// The name of the first route to show. /// The name of the first route to show.
final String initialRoute; final String initialRoute;
......
...@@ -27,12 +27,11 @@ class OrientationBuilder extends StatelessWidget { ...@@ -27,12 +27,11 @@ class OrientationBuilder extends StatelessWidget {
/// Creates an orientation builder. /// Creates an orientation builder.
/// ///
/// The [builder] argument must not be null. /// The [builder] argument must not be null.
OrientationBuilder({ const OrientationBuilder({
Key key, Key key,
@required this.builder, @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. /// Builds the widgets below this widget given this widget's orientation.
final OrientationWidgetBuilder builder; final OrientationWidgetBuilder builder;
......
...@@ -201,12 +201,11 @@ class Overlay extends StatefulWidget { ...@@ -201,12 +201,11 @@ class Overlay extends StatefulWidget {
/// Rather than creating an overlay, consider using the overlay that has /// Rather than creating an overlay, consider using the overlay that has
/// already been created by the [WidgetsApp] or the [MaterialApp] for this /// already been created by the [WidgetsApp] or the [MaterialApp] for this
/// application. /// application.
Overlay({ const Overlay({
Key key, Key key,
this.initialEntries: const <OverlayEntry>[] this.initialEntries: const <OverlayEntry>[]
}) : super(key: key) { }) : assert(initialEntries != null),
assert(initialEntries != null); super(key: key);
}
/// The entries to include in the overlay initially. /// The entries to include in the overlay initially.
/// ///
......
...@@ -33,19 +33,18 @@ class GlowingOverscrollIndicator extends StatefulWidget { ...@@ -33,19 +33,18 @@ class GlowingOverscrollIndicator extends StatefulWidget {
/// ///
/// The [showLeading], [showTrailing], [axisDirection], and [color] arguments /// The [showLeading], [showTrailing], [axisDirection], and [color] arguments
/// must not be null. /// must not be null.
GlowingOverscrollIndicator({ const GlowingOverscrollIndicator({
Key key, Key key,
this.showLeading: true, this.showLeading: true,
this.showTrailing: true, this.showTrailing: true,
@required this.axisDirection, @required this.axisDirection,
@required this.color, @required this.color,
this.child, this.child,
}) : super(key: key) { }) : assert(showLeading != null),
assert(showLeading != null); assert(showTrailing != null),
assert(showTrailing != null); assert(axisDirection != null),
assert(axisDirection != null); assert(color != null),
assert(color != null); super(key: key);
}
/// Whether to show the overscroll glow on the side with negative scroll /// Whether to show the overscroll glow on the side with negative scroll
/// offsets. /// offsets.
......
...@@ -104,13 +104,12 @@ class PageStorage extends StatelessWidget { ...@@ -104,13 +104,12 @@ class PageStorage extends StatelessWidget {
/// Creates a widget that provides a storage bucket for its descendants. /// Creates a widget that provides a storage bucket for its descendants.
/// ///
/// The [bucket] argument must not be null. /// The [bucket] argument must not be null.
PageStorage({ const PageStorage({
Key key, Key key,
@required this.bucket, @required this.bucket,
@required this.child @required this.child
}) : super(key: key) { }) : assert(bucket != null),
assert(bucket != null); super(key: key);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
......
...@@ -8,13 +8,12 @@ import 'framework.dart'; ...@@ -8,13 +8,12 @@ import 'framework.dart';
import 'scroll_controller.dart'; import 'scroll_controller.dart';
class PrimaryScrollController extends InheritedWidget { class PrimaryScrollController extends InheritedWidget {
PrimaryScrollController({ const PrimaryScrollController({
Key key, Key key,
@required this.controller, @required this.controller,
@required Widget child @required Widget child
}) : super(key: key, child: child) { }) : assert(controller != null),
assert(controller != null); super(key: key, child: child);
}
const PrimaryScrollController.none({ const PrimaryScrollController.none({
Key key, Key key,
......
...@@ -28,15 +28,14 @@ class RawKeyboardListener extends StatefulWidget { ...@@ -28,15 +28,14 @@ class RawKeyboardListener extends StatefulWidget {
/// ///
/// For text entry, consider using a [EditableText], which integrates with /// For text entry, consider using a [EditableText], which integrates with
/// on-screen keyboards and input method editors (IMEs). /// on-screen keyboards and input method editors (IMEs).
RawKeyboardListener({ const RawKeyboardListener({
Key key, Key key,
@required this.focusNode, @required this.focusNode,
@required this.onKey, @required this.onKey,
@required this.child, @required this.child,
}) : super(key: key) { }) : assert(focusNode != null),
assert(focusNode != null); assert(child != null),
assert(child != null); super(key: key);
}
/// Controls whether this widget has keyboard focus. /// Controls whether this widget has keyboard focus.
final FocusNode focusNode; final FocusNode focusNode;
......
...@@ -354,18 +354,17 @@ abstract class LocalHistoryRoute<T> extends Route<T> { ...@@ -354,18 +354,17 @@ abstract class LocalHistoryRoute<T> extends Route<T> {
} }
class _ModalScopeStatus extends InheritedWidget { class _ModalScopeStatus extends InheritedWidget {
_ModalScopeStatus({ const _ModalScopeStatus({
Key key, Key key,
@required this.isCurrent, @required this.isCurrent,
@required this.canPop, @required this.canPop,
@required this.route, @required this.route,
@required Widget child @required Widget child
}) : super(key: key, child: child) { }) : assert(isCurrent != null),
assert(isCurrent != null); assert(canPop != null),
assert(canPop != null); assert(route != null),
assert(route != null); assert(child != null),
assert(child != null); super(key: key, child: child);
}
final bool isCurrent; final bool isCurrent;
final bool canPop; final bool canPop;
......
...@@ -25,16 +25,15 @@ export 'package:flutter/physics.dart' show Tolerance; ...@@ -25,16 +25,15 @@ export 'package:flutter/physics.dart' show Tolerance;
typedef Widget ViewportBuilder(BuildContext context, ViewportOffset position); typedef Widget ViewportBuilder(BuildContext context, ViewportOffset position);
class Scrollable extends StatefulWidget { class Scrollable extends StatefulWidget {
Scrollable({ const Scrollable({
Key key, Key key,
this.axisDirection: AxisDirection.down, this.axisDirection: AxisDirection.down,
this.controller, this.controller,
this.physics, this.physics,
@required this.viewportBuilder, @required this.viewportBuilder,
}) : super (key: key) { }) : assert(axisDirection != null),
assert(axisDirection != null); assert(viewportBuilder != null),
assert(viewportBuilder != null); super (key: key);
}
final AxisDirection axisDirection; final AxisDirection axisDirection;
...@@ -100,15 +99,14 @@ class Scrollable extends StatefulWidget { ...@@ -100,15 +99,14 @@ class Scrollable extends StatefulWidget {
// Enable Scrollable.of() to work as if ScrollableState was an inherited widget. // Enable Scrollable.of() to work as if ScrollableState was an inherited widget.
// ScrollableState.build() always rebuilds its _ScrollableScope. // ScrollableState.build() always rebuilds its _ScrollableScope.
class _ScrollableScope extends InheritedWidget { class _ScrollableScope extends InheritedWidget {
_ScrollableScope({ const _ScrollableScope({
Key key, Key key,
@required this.scrollable, @required this.scrollable,
@required this.position, @required this.position,
@required Widget child @required Widget child
}) : super(key: key, child: child) { }) : assert(scrollable != null),
assert(scrollable != null); assert(child != null),
assert(child != null); super(key: key, child: child);
}
final ScrollableState scrollable; final ScrollableState scrollable;
final ScrollPosition position; final ScrollPosition position;
......
...@@ -146,14 +146,13 @@ class SingleChildScrollView extends StatelessWidget { ...@@ -146,14 +146,13 @@ class SingleChildScrollView extends StatelessWidget {
} }
class _SingleChildViewport extends SingleChildRenderObjectWidget { class _SingleChildViewport extends SingleChildRenderObjectWidget {
_SingleChildViewport({ const _SingleChildViewport({
Key key, Key key,
this.axisDirection: AxisDirection.down, this.axisDirection: AxisDirection.down,
this.offset, this.offset,
Widget child, Widget child,
}) : super(key: key, child: child) { }) : assert(axisDirection != null),
assert(axisDirection != null); super(key: key, child: child);
}
final AxisDirection axisDirection; final AxisDirection axisDirection;
final ViewportOffset offset; final ViewportOffset offset;
......
...@@ -426,14 +426,13 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget { ...@@ -426,14 +426,13 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget {
/// extent in the main axis. /// extent in the main axis.
class SliverFillViewport extends SliverMultiBoxAdaptorWidget { class SliverFillViewport extends SliverMultiBoxAdaptorWidget {
/// Creates a sliver whose box children that each fill the viewport. /// Creates a sliver whose box children that each fill the viewport.
SliverFillViewport({ const SliverFillViewport({
Key key, Key key,
@required SliverChildDelegate delegate, @required SliverChildDelegate delegate,
this.viewportFraction: 1.0, this.viewportFraction: 1.0,
}) : super(key: key, delegate: delegate) { }) : assert(viewportFraction != null),
assert(viewportFraction != null); assert(viewportFraction > 0.0),
assert(viewportFraction > 0.0); super(key: key, delegate: delegate);
}
/// The fraction of the viewport that each child should fill in the main axis. /// The fraction of the viewport that each child should fill in the main axis.
/// ///
......
...@@ -29,16 +29,15 @@ abstract class SliverPersistentHeaderDelegate { ...@@ -29,16 +29,15 @@ abstract class SliverPersistentHeaderDelegate {
} }
class SliverPersistentHeader extends StatelessWidget { class SliverPersistentHeader extends StatelessWidget {
SliverPersistentHeader({ const SliverPersistentHeader({
Key key, Key key,
@required this.delegate, @required this.delegate,
this.pinned: false, this.pinned: false,
this.floating: false, this.floating: false,
}) : super(key: key) { }) : assert(delegate != null),
assert(delegate != null); assert(pinned != null),
assert(pinned != null); assert(floating != null),
assert(floating != null); super(key: key);
}
final SliverPersistentHeaderDelegate delegate; final SliverPersistentHeaderDelegate delegate;
......
...@@ -19,13 +19,12 @@ class TickerMode extends InheritedWidget { ...@@ -19,13 +19,12 @@ class TickerMode extends InheritedWidget {
/// Creates a widget that enables or disables tickers. /// Creates a widget that enables or disables tickers.
/// ///
/// The [enabled] argument must not be null. /// The [enabled] argument must not be null.
TickerMode({ const TickerMode({
Key key, Key key,
@required this.enabled, @required this.enabled,
Widget child 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. /// The current ticker mode of this subtree.
/// ///
......
...@@ -219,15 +219,14 @@ class SizeTransition extends AnimatedWidget { ...@@ -219,15 +219,14 @@ class SizeTransition extends AnimatedWidget {
/// The [sizeFactor] argument must not be null. The [axis] argument defaults /// The [sizeFactor] argument must not be null. The [axis] argument defaults
/// to [Axis.vertical]. The [axisAlignment] defaults to 0.5, which centers the /// to [Axis.vertical]. The [axisAlignment] defaults to 0.5, which centers the
/// child along the main axis during the transition. /// child along the main axis during the transition.
SizeTransition({ const SizeTransition({
Key key, Key key,
this.axis: Axis.vertical, this.axis: Axis.vertical,
@required Animation<double> sizeFactor, @required Animation<double> sizeFactor,
this.axisAlignment: 0.5, this.axisAlignment: 0.5,
this.child, 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]. /// [Axis.horizontal] if [sizeFactor] modifies the width, otherwise [Axis.vertical].
final Axis axis; final Axis axis;
...@@ -465,14 +464,13 @@ class AnimatedBuilder extends AnimatedWidget { ...@@ -465,14 +464,13 @@ class AnimatedBuilder extends AnimatedWidget {
/// Creates an animated builder. /// Creates an animated builder.
/// ///
/// The [animation] and [builder] arguments must not be null. /// The [animation] and [builder] arguments must not be null.
AnimatedBuilder({ const AnimatedBuilder({
Key key, Key key,
@required Listenable animation, @required Listenable animation,
@required this.builder, @required this.builder,
this.child, 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. /// Called every time the animation changes value.
final TransitionBuilder builder; final TransitionBuilder builder;
......
...@@ -19,13 +19,12 @@ class WillPopScope extends StatefulWidget { ...@@ -19,13 +19,12 @@ class WillPopScope extends StatefulWidget {
/// dismiss the enclosing [ModalRoute]. /// dismiss the enclosing [ModalRoute].
/// ///
/// The [child] argument must not be null. /// The [child] argument must not be null.
WillPopScope({ const WillPopScope({
Key key, Key key,
@required this.child, @required this.child,
@required this.onWillPop, @required this.onWillPop,
}) : super(key: key) { }) : assert(child != null),
assert(child != null); super(key: key);
}
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
......
...@@ -9,18 +9,18 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -9,18 +9,18 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('Activity indicator animate property works', (WidgetTester tester) async { 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)); 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)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
await tester.pumpWidget(new Container()); 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)); 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)); expect(SchedulerBinding.instance.transientCallbackCount, equals(1));
}); });
} }
...@@ -15,7 +15,7 @@ const TextStyle testStyle = const TextStyle( ...@@ -15,7 +15,7 @@ const TextStyle testStyle = const TextStyle(
void main() { void main() {
testWidgets('Default layout minimum size', (WidgetTester tester) async { testWidgets('Default layout minimum size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center(child: new CupertinoButton( const Center(child: const CupertinoButton(
child: const Text('X', style: testStyle), child: const Text('X', style: testStyle),
onPressed: null, onPressed: null,
)) ))
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
testWidgets('Size grows with text', (WidgetTester tester) async { testWidgets('Size grows with text', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center(child: new CupertinoButton( const Center(child: const CupertinoButton(
child: const Text('XXXX', style: testStyle), child: const Text('XXXX', style: testStyle),
onPressed: null, onPressed: null,
)) ))
...@@ -61,7 +61,7 @@ void main() { ...@@ -61,7 +61,7 @@ void main() {
}); });
testWidgets('Button with background is wider', (WidgetTester tester) async { 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), child: const Text('X', style: testStyle),
onPressed: null, onPressed: null,
color: const Color(0xFFFFFFFF), color: const Color(0xFFFFFFFF),
...@@ -75,7 +75,7 @@ void main() { ...@@ -75,7 +75,7 @@ void main() {
}); });
testWidgets('Custom padding', (WidgetTester tester) async { 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), child: const Text(' ', style: testStyle),
onPressed: null, onPressed: null,
padding: const EdgeInsets.all(100.0), padding: const EdgeInsets.all(100.0),
...@@ -116,7 +116,7 @@ void main() { ...@@ -116,7 +116,7 @@ void main() {
}); });
testWidgets('Disabled button doesn\'t animate', (WidgetTester tester) async { 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'), child: const Text('Tap me'),
onPressed: null, onPressed: null,
))); )));
......
...@@ -23,7 +23,7 @@ void main() { ...@@ -23,7 +23,7 @@ void main() {
title: const Text('The title'), title: const Text('The title'),
content: const Text('The content'), content: const Text('The content'),
actions: <Widget>[ actions: <Widget>[
new CupertinoDialogAction( const CupertinoDialogAction(
child: const Text('Cancel'), child: const Text('Cancel'),
), ),
new CupertinoDialogAction( new CupertinoDialogAction(
...@@ -64,7 +64,7 @@ void main() { ...@@ -64,7 +64,7 @@ void main() {
}); });
testWidgets('Dialog action styles', (WidgetTester tester) async { testWidgets('Dialog action styles', (WidgetTester tester) async {
await tester.pumpWidget(new CupertinoDialogAction( await tester.pumpWidget(const CupertinoDialogAction(
isDestructive: true, isDestructive: true,
child: const Text('Ok'), child: const Text('Ok'),
)); ));
......
...@@ -67,7 +67,7 @@ void main() { ...@@ -67,7 +67,7 @@ void main() {
testWidgets('About box logic defaults to executable name for app name', (WidgetTester tester) async { testWidgets('About box logic defaults to executable name for app name', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Material(child: const AboutListTile()), const Material(child: const AboutListTile()),
); );
expect(find.text('About flutter_tester'), findsOneWidget); expect(find.text('About flutter_tester'), findsOneWidget);
}); });
......
...@@ -9,10 +9,10 @@ void main() { ...@@ -9,10 +9,10 @@ void main() {
testWidgets('BackButton control test', (WidgetTester tester) async { testWidgets('BackButton control test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new Material(child: const Text('Home')), home: const Material(child: const Text('Home')),
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/next': (BuildContext context) { '/next': (BuildContext context) {
return new Material( return const Material(
child: const Center( child: const Center(
child: const BackButton(), child: const BackButton(),
) )
......
...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('debugCheckHasMaterial control test', (WidgetTester tester) async { testWidgets('debugCheckHasMaterial control test', (WidgetTester tester) async {
await tester.pumpWidget(new FlatButton( await tester.pumpWidget(const FlatButton(
onPressed: null, onPressed: null,
child: const Text('Go'), child: const Text('Go'),
)); ));
......
...@@ -100,7 +100,7 @@ void main() { ...@@ -100,7 +100,7 @@ void main() {
testWidgets('Simple dialog control test', (WidgetTester tester) async { testWidgets('Simple dialog control test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new Material( home: const Material(
child: const Center( child: const Center(
child: const RaisedButton( child: const RaisedButton(
onPressed: null, onPressed: null,
...@@ -141,7 +141,7 @@ void main() { ...@@ -141,7 +141,7 @@ void main() {
testWidgets('Barrier dismissible', (WidgetTester tester) async { testWidgets('Barrier dismissible', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
home: new Material( home: const Material(
child: const Center( child: const Center(
child: const RaisedButton( child: const RaisedButton(
onPressed: null, onPressed: null,
......
...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('Divider control test', (WidgetTester tester) async { 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)); final RenderBox box = tester.firstRenderObject(find.byType(Divider));
expect(box.size.height, 15.0); expect(box.size.height, 15.0);
}); });
......
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
child: const Text('header') child: const Text('header')
) )
), ),
new ListTile( const ListTile(
leading: const Icon(Icons.archive), leading: const Icon(Icons.archive),
title: const Text('Archive') title: const Text('Archive')
) )
......
...@@ -31,9 +31,9 @@ void main() { ...@@ -31,9 +31,9 @@ void main() {
testWidgets('ExpandIcon disabled', (WidgetTester tester) async { testWidgets('ExpandIcon disabled', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Material( const Material(
child: new Center( child: const Center(
child: new ExpandIcon( child: const ExpandIcon(
onPressed: null onPressed: null
) )
) )
......
...@@ -36,7 +36,7 @@ void main() { ...@@ -36,7 +36,7 @@ void main() {
expect(tester.getBottomLeft(find.byKey(headerKey)).dy, expect(tester.getBottomLeft(find.byKey(headerKey)).dy,
lessThan(tester.getTopLeft(find.byKey(footerKey)).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); expect(find.text('Simple'), findsOneWidget);
}); });
......
...@@ -35,8 +35,8 @@ void main() { ...@@ -35,8 +35,8 @@ void main() {
testWidgets('Icon sizing - sized theme', (WidgetTester tester) async { testWidgets('Icon sizing - sized theme', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center( const Center(
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(size: 36.0), data: const IconThemeData(size: 36.0),
child: const Icon(null), child: const Icon(null),
), ),
...@@ -49,8 +49,8 @@ void main() { ...@@ -49,8 +49,8 @@ void main() {
testWidgets('Icon sizing - sized theme, explicit size', (WidgetTester tester) async { testWidgets('Icon sizing - sized theme, explicit size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center( const Center(
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(size: 36.0), data: const IconThemeData(size: 36.0),
child: const Icon( child: const Icon(
null, null,
...@@ -66,8 +66,8 @@ void main() { ...@@ -66,8 +66,8 @@ void main() {
testWidgets('Icon sizing - sizeless theme, default size', (WidgetTester tester) async { testWidgets('Icon sizing - sizeless theme, default size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center( const Center(
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(), data: const IconThemeData(),
child: const Icon(null), child: const Icon(null),
), ),
......
...@@ -27,8 +27,8 @@ void main() { ...@@ -27,8 +27,8 @@ void main() {
testWidgets('Icon opacity', (WidgetTester tester) async { testWidgets('Icon opacity', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center( const Center(
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(opacity: 0.5), data: const IconThemeData(opacity: 0.5),
child: const ImageIcon(_kImage), child: const ImageIcon(_kImage),
), ),
...@@ -56,8 +56,8 @@ void main() { ...@@ -56,8 +56,8 @@ void main() {
testWidgets('ImageIcon sizing - sized theme', (WidgetTester tester) async { testWidgets('ImageIcon sizing - sized theme', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center( const Center(
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(size: 36.0), data: const IconThemeData(size: 36.0),
child: const ImageIcon(null) child: const ImageIcon(null)
) )
...@@ -70,8 +70,8 @@ void main() { ...@@ -70,8 +70,8 @@ void main() {
testWidgets('ImageIcon sizing - sized theme, explicit size', (WidgetTester tester) async { testWidgets('ImageIcon sizing - sized theme, explicit size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center( const Center(
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(size: 36.0), data: const IconThemeData(size: 36.0),
child: const ImageIcon( child: const ImageIcon(
null, null,
...@@ -87,8 +87,8 @@ void main() { ...@@ -87,8 +87,8 @@ void main() {
testWidgets('ImageIcon sizing - sizeless theme, default size', (WidgetTester tester) async { testWidgets('ImageIcon sizing - sizeless theme, default size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Center( const Center(
child: new IconTheme( child: const IconTheme(
data: const IconThemeData(), data: const IconThemeData(),
child: const ImageIcon(null) child: const ImageIcon(null)
) )
......
...@@ -11,10 +11,10 @@ void main() { ...@@ -11,10 +11,10 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
theme: new ThemeData(platform: TargetPlatform.android), theme: new ThemeData(platform: TargetPlatform.android),
home: new Material(child: const Text('Page 1')), home: const Material(child: const Text('Page 1')),
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/next': (BuildContext context) { '/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() { ...@@ -62,7 +62,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
theme: new ThemeData(platform: TargetPlatform.iOS), theme: new ThemeData(platform: TargetPlatform.iOS),
home: new Material(child: const Text('Page 1')), home: const Material(child: const Text('Page 1')),
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/next': (BuildContext context) { '/next': (BuildContext context) {
return new Material( return new Material(
...@@ -141,7 +141,7 @@ void main() { ...@@ -141,7 +141,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
theme: new ThemeData(platform: TargetPlatform.iOS), 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() { ...@@ -149,7 +149,7 @@ void main() {
tester.state<NavigatorState>(find.byType(Navigator)).push(new MaterialPageRoute<Null>( tester.state<NavigatorState>(find.byType(Navigator)).push(new MaterialPageRoute<Null>(
builder: (BuildContext context) { builder: (BuildContext context) {
return new Material(child: const Text('Page 2')); return const Material(child: const Text('Page 2'));
}, },
fullscreenDialog: true, fullscreenDialog: true,
)); ));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment