Constants! Constants everywhere! (#9286)

Aggressively apply the const lint.
This commit is contained in:
Ian Hickson 2017-04-07 12:24:32 -07:00 committed by GitHub
parent 54bbb6fb4d
commit 3eb87830e9
197 changed files with 1312 additions and 1315 deletions

View File

@ -14,7 +14,7 @@ class TestTestBinding extends AutomatedTestWidgetsFlutterBinding {
Future<Null> guardedHelper(WidgetTester tester) {
return TestAsyncUtils.guard(() async {
await tester.pumpWidget(new Text('Hello'));
await tester.pumpWidget(const Text('Hello'));
});
}

View File

@ -57,7 +57,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Advanced Layout'),
title: const Text('Advanced Layout'),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.create),
@ -356,9 +356,9 @@ class UserHeader extends StatelessWidget {
class ItemDescription extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Padding(
return const Padding(
padding: const EdgeInsets.all(8.0),
child: new Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.')
child: const Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.')
);
}
}
@ -579,7 +579,7 @@ class GalleryDrawer extends StatelessWidget {
new FancyDrawerHeader(),
new ListTile(
leading: new Icon(Icons.brightness_5),
title: new Text('Light'),
title: const Text('Light'),
onTap: () { _changeTheme(context, true); },
selected: ComplexLayoutApp.of(context).lightTheme,
trailing: new Radio<bool>(
@ -590,7 +590,7 @@ class GalleryDrawer extends StatelessWidget {
),
new ListTile(
leading: new Icon(Icons.brightness_7),
title: new Text('Dark'),
title: const Text('Dark'),
onTap: () { _changeTheme(context, false); },
selected: !ComplexLayoutApp.of(context).lightTheme,
trailing: new Radio<bool>(
@ -602,7 +602,7 @@ class GalleryDrawer extends StatelessWidget {
new Divider(),
new ListTile(
leading: new Icon(Icons.hourglass_empty),
title: new Text('Animate Slowly'),
title: const Text('Animate Slowly'),
selected: timeDilation != 1.0,
onTap: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); },
trailing: new Checkbox(

View File

@ -15,7 +15,7 @@ import 'package:stack_trace/stack_trace.dart';
String cwd = Directory.current.path;
List<ProcessInfo> _runningProcesses = <ProcessInfo>[];
ProcessManager _processManager = new LocalProcessManager();
ProcessManager _processManager = const LocalProcessManager();
class ProcessInfo {
ProcessInfo(this.command, this.process);

View File

@ -10,7 +10,7 @@ import 'package:process/process.dart';
import 'package:test/test.dart';
void main() {
final ProcessManager processManager = new LocalProcessManager();
final ProcessManager processManager = const LocalProcessManager();
group('run.dart script', () {
Future<int> runScript(List<String> testNames) async {

View File

@ -88,7 +88,7 @@ class CardCollectionState extends State<CardCollection> {
data: const IconThemeData(color: Colors.black),
child: new ListView(
children: <Widget>[
new DrawerHeader(child: new Center(child: new Text('Options'))),
const DrawerHeader(child: const Center(child: const Text('Options'))),
buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable),
buildDrawerCheckbox("Fixed size cards", _fixedSizeCards, _toggleFixedSizeCards),
buildDrawerCheckbox("Let the sun shine", _sunshine, _toggleSunshine),
@ -110,7 +110,7 @@ class CardCollectionState extends State<CardCollection> {
new ListTile(
leading: new Icon(Icons.dvr),
onTap: () { debugDumpApp(); debugDumpRenderTree(); },
title: new Text('Dump App to Console'),
title: const Text('Dump App to Console'),
),
],
),

View File

@ -42,7 +42,7 @@ class ExampleDragTargetState extends State<ExampleDragTarget> {
}
class Dot extends StatefulWidget {
Dot({ Key key, this.color, this.size, this.child, this.tappable: false }) : super(key: key);
const Dot({ Key key, this.color, this.size, this.child, this.tappable: false }) : super(key: key);
final Color color;
final double size;
@ -193,13 +193,13 @@ class MovableBall extends StatelessWidget {
color: Colors.blue.shade700,
size: kBallSize,
tappable: true,
child: new Center(child: new Text('BALL'))
child: const Center(child: const Text('BALL'))
)
);
final Widget dashedBall = new Container(
width: kBallSize,
height: kBallSize,
child: new CustomPaint(
child: const CustomPaint(
painter: const DashOutlineCirclePainter()
)
);
@ -238,7 +238,7 @@ class DragAndDropAppState extends State<DragAndDropApp> {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Drag and Drop Flutter Demo')
title: const Text('Drag and Drop Flutter Demo')
),
body: new Column(
children: <Widget>[
@ -251,19 +251,19 @@ class DragAndDropAppState extends State<DragAndDropApp> {
color: Colors.yellow.shade300,
under: true,
heavy: false,
child: new Text('under')
child: const Text('under')
),
new ExampleDragSource(
color: Colors.green.shade300,
under: false,
heavy: true,
child: new Text('long-press above')
child: const Text('long-press above')
),
new ExampleDragSource(
color: Colors.indigo.shade300,
under: false,
heavy: false,
child: new Text('above')
child: const Text('above')
),
],
)

View File

@ -444,7 +444,7 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM
length: _allDemos.length,
child: new Scaffold(
appBar: new AppBar(
title: new Text('Animation'),
title: const Text('Animation'),
bottom: new TabBar(
tabs: _allDemos.map((_ArcDemo demo) => new Tab(text: demo.title)).toList(),
),

View File

@ -181,7 +181,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
Widget build(BuildContext context) {
final List<Widget> layers = <Widget>[
new Scaffold(
appBar: new AppBar(title: new Text('Tap a Card')),
appBar: new AppBar(title: const Text('Tap a Card')),
body: new Container(
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0),
child: new NotificationListener<ScrollNotification>(

View File

@ -84,22 +84,22 @@ class PageViewAppState extends State<PageViewApp> {
return new Drawer(
child: new ListView(
children: <Widget>[
new DrawerHeader(child: new Center(child: new Text('Options'))),
const DrawerHeader(child: const Center(child: const Text('Options'))),
new ListTile(
leading: new Icon(Icons.more_horiz),
selected: scrollDirection == Axis.horizontal,
trailing: new Text('Horizontal Layout'),
trailing: const Text('Horizontal Layout'),
onTap: switchScrollDirection,
),
new ListTile(
leading: new Icon(Icons.more_vert),
selected: scrollDirection == Axis.vertical,
trailing: new Text('Vertical Layout'),
trailing: const Text('Vertical Layout'),
onTap: switchScrollDirection,
),
new ListTile(
onTap: toggleItemsWrap,
title: new Text('Scrolling wraps around'),
title: const Text('Scrolling wraps around'),
// TODO(abarth): Actually make this checkbox change this value.
trailing: new Checkbox(value: itemsWrap, onChanged: null),
),
@ -110,7 +110,7 @@ class PageViewAppState extends State<PageViewApp> {
Widget _buildAppBar() {
return new AppBar(
title: new Text('PageView'),
title: const Text('PageView'),
actions: <Widget>[
new Text(scrollDirection == Axis.horizontal ? "horizontal" : "vertical"),
],

View File

@ -10,7 +10,7 @@ void main() {
title: 'Hardware Key Demo',
home: new Scaffold(
appBar: new AppBar(
title: new Text('Hardware Key Demo'),
title: const Text('Hardware Key Demo'),
),
body: new Center(
child: new RawKeyboardDemo(),

View File

@ -125,7 +125,7 @@ class ColorsDemo extends StatelessWidget {
child: new Scaffold(
appBar: new AppBar(
elevation: 0,
title: new Text('Colors'),
title: const Text('Colors'),
bottom: new TabBar(
isScrollable: true,
tabs: allPalettes.map((Palette swatch) => new Tab(text: swatch.name)).toList(),

View File

@ -113,11 +113,11 @@ class ContactsDemoState extends State<ContactsDemo> {
floating: _appBarBehavior == AppBarBehavior.floating,
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.create),
icon: const Icon(Icons.create),
tooltip: 'Edit',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('This is actually just a demo. Editing isn\'t supported.')
content: const Text('This is actually just a demo. Editing isn\'t supported.')
));
},
),
@ -130,21 +130,21 @@ class ContactsDemoState extends State<ContactsDemo> {
itemBuilder: (BuildContext context) => <PopupMenuItem<AppBarBehavior>>[
new PopupMenuItem<AppBarBehavior>(
value: AppBarBehavior.normal,
child: new Text('App bar scrolls away')
child: const Text('App bar scrolls away')
),
new PopupMenuItem<AppBarBehavior>(
value: AppBarBehavior.pinned,
child: new Text('App bar stays put')
child: const Text('App bar stays put')
),
new PopupMenuItem<AppBarBehavior>(
value: AppBarBehavior.floating,
child: new Text('App bar floats')
child: const Text('App bar floats')
),
],
),
],
flexibleSpace: new FlexibleSpaceBar(
title: new Text('Ali Connors'),
title: const Text('Ali Connors'),
background: new Stack(
children: <Widget>[
new Image.asset(
@ -154,7 +154,7 @@ class ContactsDemoState extends State<ContactsDemo> {
),
// This gradient ensures that the toolbar icons are distinct
// against the background image.
new DecoratedBox(
const DecoratedBox(
decoration: const BoxDecoration(
gradient: const LinearGradient(
begin: const FractionalOffset(0.5, 0.0),
@ -177,7 +177,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Send message',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Pretend that this opened your SMS application.')
content: const Text('Pretend that this opened your SMS application.')
));
},
lines: <String>[
@ -190,7 +190,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Send message',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('In this demo, this button doesn\'t do anything.')
content: const Text('In this demo, this button doesn\'t do anything.')
));
},
lines: <String>[
@ -203,7 +203,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Send message',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Imagine if you will, a messaging application.')
content: const Text('Imagine if you will, a messaging application.')
));
},
lines: <String>[
@ -221,7 +221,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Send personal e-mail',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Here, your e-mail application would open.')
content: const Text('Here, your e-mail application would open.')
));
},
lines: <String>[
@ -234,7 +234,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Send work e-mail',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new 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.')
));
},
lines: <String>[
@ -252,7 +252,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Open map',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('This would show a map of San Francisco.')
content: const Text('This would show a map of San Francisco.')
));
},
lines: <String>[
@ -266,7 +266,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Open map',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('This would show a map of Mountain View.')
content: const Text('This would show a map of Mountain View.')
));
},
lines: <String>[
@ -280,7 +280,7 @@ class ContactsDemoState extends State<ContactsDemo> {
tooltip: 'Open map',
onPressed: () {
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new 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.')
));
},
lines: <String>[

View File

@ -12,7 +12,7 @@ class CupertinoProgressIndicatorDemo extends StatelessWidget {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Cupertino Activity Indicator'),
title: const Text('Cupertino Activity Indicator'),
),
body: new Center(
child: new CupertinoActivityIndicator(),

View File

@ -21,13 +21,13 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Cupertino Buttons'),
title: const Text('Cupertino Buttons'),
),
body: new Column(
children: <Widget> [
new Padding(
const Padding(
padding: const EdgeInsets.all(16.0),
child: new Text('iOS themed buttons are flat. They can have borders or backgrounds but '
child: const Text('iOS themed buttons are flat. They can have borders or backgrounds but '
'only when necessary.'),
),
new Expanded(
@ -35,36 +35,36 @@ class _CupertinoButtonDemoState extends State<CupertinoButtonsDemo> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget> [
new Text(_pressedCount > 0 ? "Button pressed $_pressedCount times" : " "),
new Padding(padding: const EdgeInsets.all(12.0)),
const Padding(padding: const EdgeInsets.all(12.0)),
new Align(
alignment: const FractionalOffset(0.5, 0.4),
child: new Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new CupertinoButton(
child: new Text('Cupertino Button'),
child: const Text('Cupertino Button'),
onPressed: () {
setState(() {_pressedCount++;});
}
),
new CupertinoButton(
child: new Text('Disabled'),
child: const Text('Disabled'),
onPressed: null,
),
],
),
),
new Padding(padding: const EdgeInsets.all(12.0)),
const Padding(padding: const EdgeInsets.all(12.0)),
new CupertinoButton(
child: new Text('With Background'),
child: const Text('With Background'),
color: _kBlue,
onPressed: () {
setState(() {_pressedCount++;});
}
),
new Padding(padding: const EdgeInsets.all(12.0)),
const Padding(padding: const EdgeInsets.all(12.0)),
new CupertinoButton(
child: new Text('Disabled'),
child: const Text('Disabled'),
color: _kBlue,
onPressed: null,
),

View File

@ -37,27 +37,27 @@ class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
title: new Text('Cupertino Dialogs'),
title: const Text('Cupertino Dialogs'),
),
body: new ListView(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
children: <Widget> [
new CupertinoButton(
child: new Text('Alert'),
child: const Text('Alert'),
color: _kBlue,
onPressed: () {
showDemoDialog<String>(
context: context,
child: new CupertinoAlertDialog(
content: new Text('Discard draft?'),
content: const Text('Discard draft?'),
actions: <Widget>[
new CupertinoDialogAction(
child: new Text('Discard'),
child: const Text('Discard'),
isDestructive: true,
onPressed: () { Navigator.pop(context, 'OK'); }
),
new CupertinoDialogAction(
child: new Text('Cancel', style: const TextStyle(fontWeight: FontWeight.w600)),
child: const Text('Cancel', style: const TextStyle(fontWeight: FontWeight.w600)),
onPressed: () { Navigator.pop(context, 'Cancel'); }
),
]
@ -65,27 +65,27 @@ class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
);
},
),
new Padding(padding: const EdgeInsets.all(8.0)),
const Padding(padding: const EdgeInsets.all(8.0)),
new CupertinoButton(
child: new Text('Alert with Title'),
child: const Text('Alert with Title'),
color: _kBlue,
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0),
onPressed: () {
showDemoDialog<String>(
context: context,
child: new CupertinoAlertDialog(
title: new Text('Allow "Maps" to access your location while you use the app?'),
content: new Text(
title: const Text('Allow "Maps" to access your location while you use the app?'),
content: const Text(
'Your current location will be displayed on the map and used for directions, '
'nearby search results, and estimated travel times.'
),
actions: <Widget>[
new CupertinoDialogAction(
child: new Text('Don\'t Allow'),
child: const Text('Don\'t Allow'),
onPressed: () { Navigator.pop(context, 'Disallow'); }
),
new CupertinoDialogAction(
child: new Text('Allow'),
child: const Text('Allow'),
onPressed: () { Navigator.pop(context, 'Allow'); }
),
]

View File

@ -20,7 +20,7 @@ class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Cupertino Sliders'),
title: const Text('Cupertino Sliders'),
),
body: new Center(
child: new Column(
@ -39,7 +39,7 @@ class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
});
}
),
new Text('Cupertino Continuous'),
const Text('Cupertino Continuous'),
]
),
new Column(
@ -56,7 +56,7 @@ class _CupertinoSliderDemoState extends State<CupertinoSliderDemo> {
});
}
),
new Text('Cupertino Discrete'),
const Text('Cupertino Discrete'),
]
),
],

View File

@ -20,7 +20,7 @@ class _CupertinoSwitchDemoState extends State<CupertinoSwitchDemo> {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Cupertino Switch'),
title: const Text('Cupertino Switch'),
),
body: new Center(
child: new CupertinoSwitch(

View File

@ -23,7 +23,7 @@ class NavigationIconView {
) {
_animation = new CurvedAnimation(
parent: controller,
curve: new Interval(0.5, 1.0, curve: Curves.fastOutSlowIn),
curve: const Interval(0.5, 1.0, curve: Curves.fastOutSlowIn),
);
}
@ -96,32 +96,32 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
super.initState();
_navigationViews = <NavigationIconView>[
new NavigationIconView(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm'),
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm'),
color: Colors.deepPurple,
vsync: this,
),
new NavigationIconView(
icon: new CustomIcon(),
title: new Text('Box'),
title: const Text('Box'),
color: Colors.deepOrange,
vsync: this,
),
new NavigationIconView(
icon: new Icon(Icons.cloud),
title: new Text('Cloud'),
icon: const Icon(Icons.cloud),
title: const Text('Cloud'),
color: Colors.teal,
vsync: this,
),
new NavigationIconView(
icon: new Icon(Icons.favorite),
title: new Text('Favorites'),
icon: const Icon(Icons.favorite),
title: const Text('Favorites'),
color: Colors.indigo,
vsync: this,
),
new NavigationIconView(
icon: new Icon(Icons.event_available),
title: new Text('Event'),
icon: const Icon(Icons.event_available),
title: const Text('Event'),
color: Colors.pink,
vsync: this,
)
@ -183,7 +183,7 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
return new Scaffold(
appBar: new AppBar(
title: new Text('Bottom navigation'),
title: const Text('Bottom navigation'),
actions: <Widget>[
new PopupMenuButton<BottomNavigationBarType>(
onSelected: (BottomNavigationBarType value) {
@ -194,11 +194,11 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
itemBuilder: (BuildContext context) => <PopupMenuItem<BottomNavigationBarType>>[
new PopupMenuItem<BottomNavigationBarType>(
value: BottomNavigationBarType.fixed,
child: new Text('Fixed'),
child: const Text('Fixed'),
),
new PopupMenuItem<BottomNavigationBarType>(
value: BottomNavigationBarType.shifting,
child: new Text('Shifting'),
child: const Text('Shifting'),
)
],
)

View File

@ -95,13 +95,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new RaisedButton(
child: new Text('RAISED BUTTON'),
child: const Text('RAISED BUTTON'),
onPressed: () {
// Perform some action
},
),
new RaisedButton(
child: new Text('DISABLED'),
child: const Text('DISABLED'),
onPressed: null,
)
],
@ -116,13 +116,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new FlatButton(
child: new Text('FLAT BUTTON'),
child: const Text('FLAT BUTTON'),
onPressed: () {
// Perform some action
},
),
new FlatButton(
child: new Text('DISABLED'),
child: const Text('DISABLED'),
onPressed: null,
)
],
@ -142,7 +142,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new ListTile(
title: new Text('Simple dropdown:'),
title: const Text('Simple dropdown:'),
trailing: new DropdownButton<String>(
value: dropdown1Value,
onChanged: (String newValue) {
@ -162,10 +162,10 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
height: 24.0,
),
new ListTile(
title: new Text('Dropdown with a hint:'),
title: const Text('Dropdown with a hint:'),
trailing: new DropdownButton<String>(
value: dropdown2Value,
hint: new Text('Choose'),
hint: const Text('Choose'),
onChanged: (String newValue) {
setState(() {
dropdown2Value = newValue;
@ -183,7 +183,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
height: 24.0,
),
new ListTile(
title: new Text('Scrollable dropdown:'),
title: const Text('Scrollable dropdown:'),
trailing: new DropdownButton<String>(
value: dropdown3Value,
onChanged: (String newValue) {
@ -218,14 +218,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new IconButton(
icon: new Icon(Icons.thumb_up),
icon: const Icon(Icons.thumb_up),
onPressed: () {
setState(() => iconButtonToggle = !iconButtonToggle);
},
color: iconButtonToggle ? Theme.of(context).primaryColor : null,
),
new IconButton(
icon: new Icon(Icons.thumb_up),
const IconButton(
icon: const Icon(Icons.thumb_up),
onPressed: null,
)
]
@ -239,7 +239,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
return new Align(
alignment: const FractionalOffset(0.5, 0.4),
child: new FloatingActionButton(
child: new Icon(Icons.add),
child: const Icon(Icons.add),
onPressed: () {
// Perform some action
},

View File

@ -116,12 +116,12 @@ class TravelDestinationItem extends StatelessWidget {
alignment: MainAxisAlignment.start,
children: <Widget>[
new FlatButton(
child: new Text('SHARE'),
child: const Text('SHARE'),
textColor: Colors.amber.shade500,
onPressed: () { /* do nothing */ },
),
new FlatButton(
child: new Text('EXPLORE'),
child: const Text('EXPLORE'),
textColor: Colors.amber.shade500,
onPressed: () { /* do nothing */ },
),
@ -142,7 +142,7 @@ class CardsDemo extends StatelessWidget {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Travel stream')
title: const Text('Travel stream')
),
body: new ListView(
itemExtent: TravelDestinationItem.height,

View File

@ -23,24 +23,24 @@ class _ChipDemoState extends State<ChipDemo> {
@override
Widget build(BuildContext context) {
final List<Widget> chips = <Widget>[
new Chip(
label: new Text('Apple')
const Chip(
label: const Text('Apple')
),
new Chip(
avatar: new CircleAvatar(child: new Text('B')),
label: new Text('Blueberry')
avatar: new CircleAvatar(child: const Text('B')),
label: const Text('Blueberry')
),
];
if (_showBananas) {
chips.add(new Chip(
label: new Text('Bananas'),
label: const Text('Bananas'),
onDeleted: _deleteBananas
));
}
return new Scaffold(
appBar: new AppBar(title: new Text('Chips')),
appBar: new AppBar(title: const Text('Chips')),
body: new ListView(
children: chips.map((Widget widget) {
return new Container(

View File

@ -164,12 +164,12 @@ class _DataTableDemoState extends State<DataTableDemo> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Data tables')),
appBar: new AppBar(title: const Text('Data tables')),
body: new ListView(
padding: const EdgeInsets.all(20.0),
children: <Widget>[
new PaginatedDataTable(
header: new Text('Nutrition'),
header: const Text('Nutrition'),
rowsPerPage: _rowsPerPage,
onRowsPerPageChanged: (int value) { setState(() { _rowsPerPage = value; }); },
sortColumnIndex: _sortColumnIndex,
@ -177,43 +177,43 @@ class _DataTableDemoState extends State<DataTableDemo> {
onSelectAll: _dessertsDataSource._selectAll,
columns: <DataColumn>[
new DataColumn(
label: new Text('Dessert (100g serving)'),
label: const Text('Dessert (100g serving)'),
onSort: (int columnIndex, bool ascending) => _sort<String>((Dessert d) => d.name, columnIndex, ascending)
),
new DataColumn(
label: new Text('Calories'),
label: const Text('Calories'),
tooltip: 'The total amount of food energy in the given serving size.',
numeric: true,
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.calories, columnIndex, ascending)
),
new DataColumn(
label: new Text('Fat (g)'),
label: const Text('Fat (g)'),
numeric: true,
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.fat, columnIndex, ascending)
),
new DataColumn(
label: new Text('Carbs (g)'),
label: const Text('Carbs (g)'),
numeric: true,
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.carbs, columnIndex, ascending)
),
new DataColumn(
label: new Text('Protein (g)'),
label: const Text('Protein (g)'),
numeric: true,
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.protein, columnIndex, ascending)
),
new DataColumn(
label: new Text('Sodium (mg)'),
label: const Text('Sodium (mg)'),
numeric: true,
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.sodium, columnIndex, ascending)
),
new DataColumn(
label: new Text('Calcium (%)'),
label: const Text('Calcium (%)'),
tooltip: 'The amount of calcium as a percentage of the recommended daily amount.',
numeric: true,
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.calcium, columnIndex, ascending)
),
new DataColumn(
label: new Text('Iron (%)'),
label: const Text('Iron (%)'),
numeric: true,
onSort: (int columnIndex, bool ascending) => _sort<num>((Dessert d) => d.iron, columnIndex, ascending)
),

View File

@ -129,7 +129,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Date and time pickers')),
appBar: new AppBar(title: const Text('Date and time pickers')),
body: new DropdownButtonHideUnderline(
child: new ListView(
padding: const EdgeInsets.all(16.0),

View File

@ -87,13 +87,13 @@ class DialogDemoState extends State<DialogDemo> {
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
title: new Text('Dialogs')
title: const Text('Dialogs')
),
body: new ListView(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
children: <Widget>[
new RaisedButton(
child: new Text('ALERT'),
child: const Text('ALERT'),
onPressed: () {
showDemoDialog<DialogDemoAction>(
context: context,
@ -104,11 +104,11 @@ class DialogDemoState extends State<DialogDemo> {
),
actions: <Widget>[
new FlatButton(
child: new Text('CANCEL'),
child: const Text('CANCEL'),
onPressed: () { Navigator.pop(context, DialogDemoAction.cancel); }
),
new FlatButton(
child: new Text('DISCARD'),
child: const Text('DISCARD'),
onPressed: () { Navigator.pop(context, DialogDemoAction.discard); }
)
]
@ -117,23 +117,23 @@ class DialogDemoState extends State<DialogDemo> {
}
),
new RaisedButton(
child: new Text('ALERT WITH TITLE'),
child: const Text('ALERT WITH TITLE'),
onPressed: () {
showDemoDialog<DialogDemoAction>(
context: context,
child: new AlertDialog(
title: new Text('Use Google\'s location service?'),
title: const Text('Use Google\'s location service?'),
content: new Text(
_alertWithTitleText,
style: dialogTextStyle
),
actions: <Widget>[
new FlatButton(
child: new Text('DISAGREE'),
child: const Text('DISAGREE'),
onPressed: () { Navigator.pop(context, DialogDemoAction.disagree); }
),
new FlatButton(
child: new Text('AGREE'),
child: const Text('AGREE'),
onPressed: () { Navigator.pop(context, DialogDemoAction.agree); }
)
]
@ -142,12 +142,12 @@ class DialogDemoState extends State<DialogDemo> {
}
),
new RaisedButton(
child: new Text('SIMPLE'),
child: const Text('SIMPLE'),
onPressed: () {
showDemoDialog<String>(
context: context,
child: new SimpleDialog(
title: new Text('Set backup account'),
title: const Text('Set backup account'),
children: <Widget>[
new DialogDemoItem(
icon: Icons.account_circle,
@ -172,7 +172,7 @@ class DialogDemoState extends State<DialogDemo> {
}
),
new RaisedButton(
child: new Text('CONFIRMATION'),
child: const Text('CONFIRMATION'),
onPressed: () {
showTimePicker(
context: context,
@ -189,7 +189,7 @@ class DialogDemoState extends State<DialogDemo> {
}
),
new RaisedButton(
child: new Text('FULLSCREEN'),
child: const Text('FULLSCREEN'),
onPressed: () {
Navigator.push(context, new MaterialPageRoute<DismissDialogAction>(
builder: (BuildContext context) => new FullScreenDialogDemo(),

View File

@ -68,7 +68,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
void _showNotImplementedMessage() {
Navigator.of(context).pop(); // Dismiss the drawer.
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text("The drawer's items don't do anything")
content: const Text("The drawer's items don't do anything")
));
}
@ -85,14 +85,14 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
Navigator.pop(context);
},
),
title: new Text('Navigation drawer'),
title: const Text('Navigation drawer'),
),
drawer: new Drawer(
child: new ListView(
children: <Widget>[
new UserAccountsDrawerHeader(
accountName: new Text('Zach Widget'),
accountEmail: new Text('zach.widget@example.com'),
accountName: const Text('Zach Widget'),
accountEmail: const Text('zach.widget@example.com'),
currentAccountPicture: new CircleAvatar(backgroundImage: new AssetImage(_kAsset0)),
otherAccountsPictures: <Widget>[
new CircleAvatar(backgroundImage: new AssetImage(_kAsset1)),
@ -134,13 +134,13 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new ListTile(
leading: new Icon(Icons.add),
title: new Text('Add account'),
leading: const Icon(Icons.add),
title: const Text('Add account'),
onTap: _showNotImplementedMessage,
),
new ListTile(
leading: new Icon(Icons.settings),
title: new Text('Manage accounts'),
leading: const Icon(Icons.settings),
title: const Text('Manage accounts'),
onTap: _showNotImplementedMessage,
),
],

View File

@ -30,8 +30,8 @@ class DualHeaderWithHint extends StatelessWidget {
return new AnimatedCrossFade(
firstChild: first,
secondChild: second,
firstCurve: new Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: new Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn),
secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn),
sizeCurve: Curves.fastOutSlowIn,
crossFadeState: isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst,
duration: const Duration(milliseconds: 200),
@ -118,7 +118,7 @@ class CollapsibleBody extends StatelessWidget {
margin: const EdgeInsets.only(right: 8.0),
child: new FlatButton(
onPressed: onCancel,
child: new Text('CANCEL', style: new TextStyle(
child: const Text('CANCEL', style: const TextStyle(
color: Colors.black54,
fontSize: 15.0,
fontWeight: FontWeight.w500
@ -130,7 +130,7 @@ class CollapsibleBody extends StatelessWidget {
child: new FlatButton(
onPressed: onSave,
textTheme: ButtonTextTheme.accent,
child: new Text('SAVE')
child: const Text('SAVE')
)
)
]
@ -254,7 +254,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
groupValue: field.value,
onChanged: field.onChanged,
),
new Text('Bahamas')
const Text('Bahamas')
]
),
new Row(
@ -265,7 +265,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
groupValue: field.value,
onChanged: field.onChanged,
),
new Text('Barbados')
const Text('Barbados')
]
),
new Row(
@ -276,7 +276,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
groupValue: field.value,
onChanged: field.onChanged,
),
new Text('Bermuda')
const Text('Bermuda')
]
)
]
@ -334,7 +334,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Expansion panels')),
appBar: new AppBar(title: const Text('Expansion panels')),
body: new SingleChildScrollView(
child: new Container(
margin: const EdgeInsets.all(24.0),

View File

@ -57,7 +57,7 @@ class DateTimeItem extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Text(new DateFormat('EEE, MMM d yyyy').format(date)),
new Icon(Icons.arrow_drop_down, color: Colors.black54),
const Icon(Icons.arrow_drop_down, color: Colors.black54),
]
)
)
@ -82,7 +82,7 @@ class DateTimeItem extends StatelessWidget {
child: new Row(
children: <Widget>[
new Text('$time'),
new Icon(Icons.arrow_drop_down, color: Colors.black54),
const Icon(Icons.arrow_drop_down, color: Colors.black54),
]
)
)
@ -122,11 +122,11 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
),
actions: <Widget>[
new FlatButton(
child: new Text('CANCEL'),
child: const Text('CANCEL'),
onPressed: () { Navigator.pop(context, DismissDialogAction.cancel); }
),
new FlatButton(
child: new Text('DISCARD'),
child: const Text('DISCARD'),
onPressed: () {
Navigator.of(context)
..pop(DismissDialogAction.discard) // pop the cancel/discard dialog
@ -145,10 +145,10 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
return new Scaffold(
appBar: new AppBar(
leading: new IconButton(
icon: new Icon(Icons.clear),
icon: const Icon(Icons.clear),
onPressed: () { handleDismissButton(context); }
),
title: new Text('New event'),
title: const Text('New event'),
actions: <Widget> [
new FlatButton(
child: new Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)),
@ -222,7 +222,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
});
}
),
new Text('All-day')
const Text('All-day')
]
)
)

View File

@ -316,22 +316,22 @@ class GridListDemoState extends State<GridListDemo> {
final Orientation orientation = MediaQuery.of(context).orientation;
return new Scaffold(
appBar: new AppBar(
title: new Text('Grid list'),
title: const Text('Grid list'),
actions: <Widget>[
new PopupMenuButton<GridDemoTileStyle>(
onSelected: changeTileStyle,
itemBuilder: (BuildContext context) => <PopupMenuItem<GridDemoTileStyle>>[
new PopupMenuItem<GridDemoTileStyle>(
value: GridDemoTileStyle.imageOnly,
child: new Text('Image only'),
child: const Text('Image only'),
),
new PopupMenuItem<GridDemoTileStyle>(
value: GridDemoTileStyle.oneLine,
child: new Text('One line'),
child: const Text('One line'),
),
new PopupMenuItem<GridDemoTileStyle>(
value: GridDemoTileStyle.twoLine,
child: new Text('Two line'),
child: const Text('Two line'),
),
],
),

View File

@ -71,7 +71,7 @@ class IconsDemoState extends State<IconsDemo> {
return new Scaffold(
appBar: new AppBar(
title: new Text('Icons')
title: const Text('Icons')
),
body: new IconTheme(
data: new IconThemeData(opacity: iconOpacity),

View File

@ -104,13 +104,13 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
background: new Container(
color: theme.primaryColor,
child: new ListTile(
leading: new Icon(Icons.delete, color: Colors.white, size: 36.0)
leading: const Icon(Icons.delete, color: Colors.white, size: 36.0)
)
),
secondaryBackground: new Container(
color: theme.primaryColor,
child: new ListTile(
trailing: new Icon(Icons.archive, color: Colors.white, size: 36.0)
trailing: const Icon(Icons.archive, color: Colors.white, size: 36.0)
)
),
child: new Container(
@ -132,30 +132,30 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
title: new Text('Swipe to dismiss'),
title: const Text('Swipe to dismiss'),
actions: <Widget>[
new PopupMenuButton<LeaveBehindDemoAction>(
onSelected: handleDemoAction,
itemBuilder: (BuildContext context) => <PopupMenuEntry<LeaveBehindDemoAction>>[
new PopupMenuItem<LeaveBehindDemoAction>(
value: LeaveBehindDemoAction.reset,
child: new Text('Reset the list')
child: const Text('Reset the list')
),
new PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771
new CheckedPopupMenuItem<LeaveBehindDemoAction>(
value: LeaveBehindDemoAction.horizontalSwipe,
checked: _dismissDirection == DismissDirection.horizontal,
child: new Text('Hoizontal swipe')
child: const Text('Hoizontal swipe')
),
new CheckedPopupMenuItem<LeaveBehindDemoAction>(
value: LeaveBehindDemoAction.leftSwipe,
checked: _dismissDirection == DismissDirection.endToStart,
child: new Text('Only swipe left')
child: const Text('Only swipe left')
),
new CheckedPopupMenuItem<LeaveBehindDemoAction>(
value: LeaveBehindDemoAction.rightSwipe,
checked: _dismissDirection == DismissDirection.startToEnd,
child: new Text('Only swipe right')
child: const Text('Only swipe right')
)
]
)

View File

@ -37,15 +37,15 @@ class _ListDemoState extends State<ListDemo> {
void _showConfigurationSheet() {
final PersistentBottomSheetController<Null> bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) {
return new Container(
decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26)),
decoration: const BoxDecoration(
border: const Border(top: const BorderSide(color: Colors.black26)),
),
child: new ListView(
shrinkWrap: true,
children: <Widget>[
new ListTile(
dense: true,
title: new Text('One-line'),
title: const Text('One-line'),
trailing: new Radio<MaterialListType>(
value: _showAvatars ? MaterialListType.oneLineWithAvatar : MaterialListType.oneLine,
groupValue: _itemType,
@ -54,7 +54,7 @@ class _ListDemoState extends State<ListDemo> {
),
new ListTile(
dense: true,
title: new Text('Two-line'),
title: const Text('Two-line'),
trailing: new Radio<MaterialListType>(
value: MaterialListType.twoLine,
groupValue: _itemType,
@ -63,7 +63,7 @@ class _ListDemoState extends State<ListDemo> {
),
new ListTile(
dense: true,
title: new Text('Three-line'),
title: const Text('Three-line'),
trailing: new Radio<MaterialListType>(
value: MaterialListType.threeLine,
groupValue: _itemType,
@ -72,7 +72,7 @@ class _ListDemoState extends State<ListDemo> {
),
new ListTile(
dense: true,
title: new Text('Show avatar'),
title: const Text('Show avatar'),
trailing: new Checkbox(
value: _showAvatars,
onChanged: (bool value) {
@ -85,7 +85,7 @@ class _ListDemoState extends State<ListDemo> {
),
new ListTile(
dense: true,
title: new Text('Show icon'),
title: const Text('Show icon'),
trailing: new Checkbox(
value: _showIcons,
onChanged: (bool value) {
@ -98,7 +98,7 @@ class _ListDemoState extends State<ListDemo> {
),
new ListTile(
dense: true,
title: new Text('Show dividers'),
title: const Text('Show dividers'),
trailing: new Checkbox(
value: _showDividers,
onChanged: (bool value) {
@ -111,7 +111,7 @@ class _ListDemoState extends State<ListDemo> {
),
new ListTile(
dense: true,
title: new Text('Dense layout'),
title: const Text('Dense layout'),
trailing: new Checkbox(
value: _dense,
onChanged: (bool value) {
@ -143,9 +143,9 @@ class _ListDemoState extends State<ListDemo> {
Widget buildListTile(BuildContext context, String item) {
Widget secondary;
if (_itemType == MaterialListType.twoLine) {
secondary = new Text("Additional item information.");
secondary = const Text("Additional item information.");
} else if (_itemType == MaterialListType.threeLine) {
secondary = new Text(
secondary = const Text(
"Even more additional list item information appears on line three.",
);
}
@ -186,7 +186,7 @@ class _ListDemoState extends State<ListDemo> {
title: new Text('Scrolling list\n$itemTypeText$layoutText'),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.sort_by_alpha),
icon: const Icon(Icons.sort_by_alpha),
tooltip: 'Sort',
onPressed: () {
setState(() {
@ -196,7 +196,7 @@ class _ListDemoState extends State<ListDemo> {
},
),
new IconButton(
icon: new Icon(Icons.more_vert),
icon: const Icon(Icons.more_vert),
tooltip: 'Show menu',
onPressed: _bottomSheet == null ? _showConfigurationSheet : null,
),

View File

@ -62,22 +62,22 @@ class MenuDemoState extends State<MenuDemo> {
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
title: new Text('Menus'),
title: const Text('Menus'),
actions: <Widget>[
new PopupMenuButton<String>(
onSelected: showMenuSelection,
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
new PopupMenuItem<String>(
value: 'Toolbar menu',
child: new Text('Toolbar menu')
child: const Text('Toolbar menu')
),
new PopupMenuItem<String>(
value: 'Right here',
child: new Text('Right here')
child: const Text('Right here')
),
new PopupMenuItem<String>(
value: 'Hooray!',
child: new Text('Hooray!')
child: const Text('Hooray!')
),
]
)
@ -90,22 +90,22 @@ class MenuDemoState extends State<MenuDemo> {
// a simple menu with one disabled item. Typically the contents
// of this "contextual menu" would reflect the app's state.
new ListTile(
title: new Text('An item with a context menu button'),
title: const Text('An item with a context menu button'),
trailing: new PopupMenuButton<String>(
padding: EdgeInsets.zero,
onSelected: showMenuSelection,
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
new PopupMenuItem<String>(
value: _simpleValue1,
child: new Text('Context menu item one')
child: const Text('Context menu item one')
),
new PopupMenuItem<String>(
enabled: false,
child: new Text('A disabled menu item')
child: const Text('A disabled menu item')
),
new PopupMenuItem<String>(
value: _simpleValue3,
child: new Text('Context menu item three')
child: const Text('Context menu item three')
),
]
)
@ -114,7 +114,7 @@ class MenuDemoState extends State<MenuDemo> {
// a menu whose items have text labels and icons and a divider
// That separates the first three items from the last one.
new ListTile(
title: new Text('An item with a sectioned menu'),
title: const Text('An item with a sectioned menu'),
trailing: new PopupMenuButton<String>(
padding: EdgeInsets.zero,
onSelected: showMenuSelection,
@ -122,30 +122,30 @@ class MenuDemoState extends State<MenuDemo> {
new PopupMenuItem<String>(
value: 'Preview',
child: new ListTile(
leading: new Icon(Icons.visibility),
title: new Text('Preview')
leading: const Icon(Icons.visibility),
title: const Text('Preview')
)
),
new PopupMenuItem<String>(
value: 'Share',
child: new ListTile(
leading: new Icon(Icons.person_add),
title: new Text('Share')
leading: const Icon(Icons.person_add),
title: const Text('Share')
)
),
new PopupMenuItem<String>(
value: 'Get Link',
child: new ListTile(
leading: new Icon(Icons.link),
title: new Text('Get link')
leading: const Icon(Icons.link),
title: const Text('Get link')
)
),
new PopupMenuDivider(), // ignore: list_element_type_not_assignable, https://github.com/flutter/flutter/issues/5771
new PopupMenuItem<String>(
value: 'Remove',
child: new ListTile(
leading: new Icon(Icons.delete),
title: new Text('Remove')
leading: const Icon(Icons.delete),
title: const Text('Remove')
)
)
]
@ -159,7 +159,7 @@ class MenuDemoState extends State<MenuDemo> {
initialValue: _simpleValue,
onSelected: showMenuSelection,
child: new ListTile(
title: new Text('An item with a simple menu'),
title: const Text('An item with a simple menu'),
subtitle: new Text(_simpleValue)
),
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
@ -180,7 +180,7 @@ class MenuDemoState extends State<MenuDemo> {
// Pressing the PopupMenuButton on the right of this item shows a menu
// whose items have checked icons that reflect this app's state.
new ListTile(
title: new Text('An item with a checklist menu'),
title: const Text('An item with a checklist menu'),
trailing: new PopupMenuButton<String>(
padding: EdgeInsets.zero,
onSelected: showCheckedMenuSelections,

View File

@ -10,10 +10,10 @@ class ModalBottomSheetDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Modal bottom sheet')),
appBar: new AppBar(title: const Text('Modal bottom sheet')),
body: new Center(
child: new RaisedButton(
child: new Text('SHOW BOTTOM SHEET'),
child: const Text('SHOW BOTTOM SHEET'),
onPressed: () {
showModalBottomSheet<Null>(context: context, builder: (BuildContext context) {
return new Container(

View File

@ -29,7 +29,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
new Timer(const Duration(seconds: 3), () { completer.complete(null); });
return completer.future.then((_) {
_scaffoldKey.currentState?.showSnackBar(new SnackBar(
content: new Text("Refresh complete"),
content: const Text("Refresh complete"),
action: new SnackBarAction(
label: 'RETRY',
onPressed: () {
@ -45,10 +45,10 @@ class OverscrollDemoState extends State<OverscrollDemo> {
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
title: new Text('Pull to refresh'),
title: const Text('Pull to refresh'),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.refresh),
icon: const Icon(Icons.refresh),
tooltip: 'Refresh',
onPressed: () {
_refreshIndicatorKey.currentState.show();
@ -68,7 +68,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
isThreeLine: true,
leading: new CircleAvatar(child: new Text(item)),
title: new Text('This item represents $item.'),
subtitle: new Text('Even more additional list item information appears on line three.'),
subtitle: const Text('Even more additional list item information appears on line three.'),
);
},
),

View File

@ -26,14 +26,14 @@ class _PageSelector extends StatelessWidget {
child: new Row(
children: <Widget>[
new IconButton(
icon: new Icon(Icons.chevron_left),
icon: const Icon(Icons.chevron_left),
color: color,
onPressed: () { _handleArrowButtonPress(context, -1); },
tooltip: 'Page back'
),
new TabPageSelector(controller: controller),
new IconButton(
icon: new Icon(Icons.chevron_right),
icon: const Icon(Icons.chevron_right),
color: color,
onPressed: () { _handleArrowButtonPress(context, 1); },
tooltip: 'Page forward'
@ -76,7 +76,7 @@ class PageSelectorDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Page selector')),
appBar: new AppBar(title: const Text('Page selector')),
body: new DefaultTabController(
length: icons.length,
child: new _PageSelector(icons: icons),

View File

@ -57,11 +57,11 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
showDialog<Null>(
context: context,
child: new AlertDialog(
content: new Text('You tapped the floating action button.'),
content: const Text('You tapped the floating action button.'),
actions: <Widget>[
new FlatButton(
onPressed: () { Navigator.pop(context); },
child: new Text('OK')
child: const Text('OK')
)
]
)
@ -72,16 +72,16 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
Widget build(BuildContext context) {
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(title: new Text('Persistent bottom sheet')),
appBar: new AppBar(title: const Text('Persistent bottom sheet')),
floatingActionButton: new FloatingActionButton(
onPressed: _showMessage,
backgroundColor: Colors.redAccent,
child: new Icon(Icons.add)
child: const Icon(Icons.add)
),
body: new Center(
child: new RaisedButton(
onPressed: _showBottomSheetCallback,
child: new Text('SHOW BOTTOM SHEET')
child: const Text('SHOW BOTTOM SHEET')
)
)
);

View File

@ -25,7 +25,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
_animation = new CurvedAnimation(
parent: _controller,
curve: new Interval(0.0, 0.9, curve: Curves.fastOutSlowIn),
curve: const Interval(0.0, 0.9, curve: Curves.fastOutSlowIn),
reverseCurve: Curves.fastOutSlowIn
)..addStatusListener((AnimationStatus status) {
if (status == AnimationStatus.dismissed)
@ -99,7 +99,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Progress indicators')),
appBar: new AppBar(title: const Text('Progress indicators')),
body: new Center(
child: new SingleChildScrollView(
child: new DefaultTextStyle(

View File

@ -59,22 +59,22 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
final Color iconColor = Theme.of(context).accentColor;
return new Scaffold(
appBar: new AppBar(
title: new Text('Scrollable tabs'),
title: const Text('Scrollable tabs'),
actions: <Widget>[
new PopupMenuButton<TabsDemoStyle>(
onSelected: changeDemoStyle,
itemBuilder: (BuildContext context) => <PopupMenuItem<TabsDemoStyle>>[
new PopupMenuItem<TabsDemoStyle>(
value: TabsDemoStyle.iconsAndText,
child: new Text('Icons and text')
child: const Text('Icons and text')
),
new PopupMenuItem<TabsDemoStyle>(
value: TabsDemoStyle.iconsOnly,
child: new Text('Icons only')
child: const Text('Icons only')
),
new PopupMenuItem<TabsDemoStyle>(
value: TabsDemoStyle.textOnly,
child: new Text('Text only')
child: const Text('Text only')
),
],
),

View File

@ -18,7 +18,7 @@ class _SliderDemoState extends State<SliderDemo> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Sliders')),
appBar: new AppBar(title: const Text('Sliders')),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -37,14 +37,14 @@ class _SliderDemoState extends State<SliderDemo> {
});
}
),
new Text('Continuous'),
const Text('Continuous'),
]
),
new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget> [
new Slider(value: 0.25, thumbOpenAtMin: true, onChanged: null),
new Text('Disabled'),
const Text('Disabled'),
]
),
new Column(
@ -63,7 +63,7 @@ class _SliderDemoState extends State<SliderDemo> {
});
}
),
new Text('Discrete'),
const Text('Discrete'),
],
),
],

View File

@ -32,11 +32,11 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
return new ListView(
padding: const EdgeInsets.all(24.0),
children: <Widget>[
new Text(_text1),
new Text(_text2),
const Text(_text1),
const Text(_text2),
new Center(
child: new RaisedButton(
child: new Text('SHOW A SNACKBAR'),
child: const Text('SHOW A SNACKBAR'),
onPressed: () {
final int thisSnackBarIndex = _snackBarIndex++;
Scaffold.of(context).showSnackBar(new SnackBar(
@ -53,7 +53,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
}
)
),
new Text(_text3),
const Text(_text3),
]
.map((Widget child) {
return new Container(
@ -69,7 +69,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Snackbar')
title: const Text('Snackbar')
),
body: new Builder(
// Create an inner BuildContext so that the snackBar onPressed methods

View File

@ -120,7 +120,7 @@ class TabsDemo extends StatelessWidget {
length: _allPages.length,
child: new Scaffold(
appBar: new AppBar(
title: new Text('Tabs and scrolling'),
title: const Text('Tabs and scrolling'),
bottom: new TabBar(
tabs: _allPages.keys.map((_Page page) => new Tab(text: page.label)).toList(),
),

View File

@ -106,7 +106,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
title: new Text('FAB per tab'),
title: const Text('FAB per tab'),
bottom: new TabBar(
controller: _controller,
tabs: _allPages.map((_Page page) => new Tab(text: page.label.toUpperCase())).toList(),

View File

@ -83,15 +83,15 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
return await showDialog<bool>(
context: context,
child: new AlertDialog(
title: new Text('This form has errors'),
content: new Text('Really leave this form?'),
title: const Text('This form has errors'),
content: const Text('Really leave this form?'),
actions: <Widget> [
new FlatButton(
child: new Text('YES'),
child: const Text('YES'),
onPressed: () { Navigator.of(context).pop(true); },
),
new FlatButton(
child: new Text('NO'),
child: const Text('NO'),
onPressed: () { Navigator.of(context).pop(false); },
),
],
@ -104,7 +104,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
return new Scaffold(
key: _scaffoldKey,
appBar: new AppBar(
title: new Text('Text fields'),
title: const Text('Text fields'),
),
body: new Form(
key: _formKey,
@ -170,7 +170,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
padding: const EdgeInsets.all(20.0),
alignment: const FractionalOffset(0.5, 0.5),
child: new RaisedButton(
child: new Text('SUBMIT'),
child: const Text('SUBMIT'),
onPressed: _handleSubmitted,
),
),

View File

@ -18,7 +18,7 @@ class TooltipDemo extends StatelessWidget {
final ThemeData theme = Theme.of(context);
return new Scaffold(
appBar: new AppBar(
title: new Text('Tooltips')
title: const Text('Tooltips')
),
body: new Builder(
builder: (BuildContext context) {
@ -42,12 +42,12 @@ class TooltipDemo extends StatelessWidget {
new Center(
child: new IconButton(
iconSize: 48.0,
icon: new Icon(Icons.call),
icon: const Icon(Icons.call),
color: theme.iconTheme.color,
tooltip: 'Place a phone call',
onPressed: () {
Scaffold.of(context).showSnackBar(new SnackBar(
content: new Text('That was an ordinary tap.')
content: const Text('That was an ordinary tap.')
));
}
)

View File

@ -10,23 +10,23 @@ class TwoLevelListDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Expand/collapse list control')),
appBar: new AppBar(title: const Text('Expand/collapse list control')),
body: new TwoLevelList(
type: MaterialListType.oneLine,
children: <Widget>[
new TwoLevelListItem(title: new Text('Top')),
new TwoLevelListItem(title: const Text('Top')),
new TwoLevelSublist(
title: new Text('Sublist'),
title: const Text('Sublist'),
backgroundColor: Theme.of(context).accentColor.withOpacity(0.025),
children: <Widget>[
new TwoLevelListItem(title: new Text('One')),
new TwoLevelListItem(title: new Text('Two')),
new TwoLevelListItem(title: const Text('One')),
new TwoLevelListItem(title: const Text('Two')),
// https://en.wikipedia.org/wiki/Free_Four
new TwoLevelListItem(title: new Text('Free')),
new TwoLevelListItem(title: new Text('Four'))
new TwoLevelListItem(title: const Text('Free')),
new TwoLevelListItem(title: const Text('Four'))
]
),
new TwoLevelListItem(title: new Text('Bottom'))
new TwoLevelListItem(title: const Text('Bottom'))
]
)
);

View File

@ -82,10 +82,10 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
child: new Scaffold(
key: scaffoldKey,
floatingActionButton: new FloatingActionButton(
child: new Icon(Icons.edit),
child: const Icon(Icons.edit),
onPressed: () {
scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Not supported.'),
content: const Text('Not supported.'),
));
},
),
@ -105,11 +105,11 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
expandedHeight: _kAppBarHeight,
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.search),
icon: const Icon(Icons.search),
tooltip: 'Search',
onPressed: () {
scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('Not supported.'),
content: const Text('Not supported.'),
));
},
),

View File

@ -181,7 +181,7 @@ class _Heading extends StatelessWidget {
),
new LayoutId(
id: _HeadingLayout.icon,
child: new Icon(
child: const Icon(
Icons.info_outline,
size: 24.0,
color: const Color(0xFFFFE0E0),
@ -275,7 +275,7 @@ class _OrderPageState extends State<OrderPage> {
);
},
backgroundColor: const Color(0xFF16F0F0),
child: new Icon(
child: const Icon(
Icons.add_shopping_cart,
color: Colors.black,
),

View File

@ -54,9 +54,9 @@ class ShrinePageState extends State<ShrinePage> {
void _showShoppingCart() {
showModalBottomSheet<Null>(context: context, builder: (BuildContext context) {
if (config.shoppingCart.isEmpty) {
return new Padding(
return const Padding(
padding: const EdgeInsets.all(24.0),
child: new Text('The shopping cart is empty')
child: const Text('The shopping cart is empty')
);
}
return new ListView(
@ -82,7 +82,7 @@ class ShrinePageState extends State<ShrinePage> {
void _emptyCart() {
config.shoppingCart.clear();
config.scaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text('Shopping cart is empty')));
config.scaffoldKey.currentState.showSnackBar(new SnackBar(content: const Text('Shopping cart is empty')));
}
@override
@ -107,7 +107,7 @@ class ShrinePageState extends State<ShrinePage> {
),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.shopping_cart),
icon: const Icon(Icons.shopping_cart),
tooltip: 'Shopping cart',
onPressed: _showShoppingCart
),
@ -115,15 +115,15 @@ class ShrinePageState extends State<ShrinePage> {
itemBuilder: (BuildContext context) => <PopupMenuItem<ShrineAction>>[
new PopupMenuItem<ShrineAction>(
value: ShrineAction.sortByPrice,
child: new Text('Sort by price')
child: const Text('Sort by price')
),
new PopupMenuItem<ShrineAction>(
value: ShrineAction.sortByProduct,
child: new Text('Sort by product')
child: const Text('Sort by product')
),
new PopupMenuItem<ShrineAction>(
value: ShrineAction.emptyCart,
child: new Text('Empty shopping cart')
child: const Text('Empty shopping cart')
)
],
onSelected: (ShrineAction action) {

View File

@ -71,7 +71,7 @@ class TypographyDemo extends StatelessWidget {
}
return new Scaffold(
appBar: new AppBar(title: new Text('Typography')),
appBar: new AppBar(title: const Text('Typography')),
body: new ListView(children: styleItems)
);
}

View File

@ -61,7 +61,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
new Builder(
builder: (BuildContext context) {
return new IconButton(
icon: new Icon(Icons.description),
icon: const Icon(Icons.description),
tooltip: 'Show example code',
onPressed: () {
_showExampleCode(context);
@ -150,10 +150,10 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
return new Scaffold(
appBar: new AppBar(
leading: new IconButton(
icon: new Icon(Icons.clear),
icon: const Icon(Icons.clear),
onPressed: () { Navigator.pop(context); }
),
title: new Text('Example code')
title: const Text('Example code')
),
body: body
);

View File

@ -127,8 +127,8 @@ class GalleryDrawer extends StatelessWidget {
final TextStyle linkStyle = themeData.textTheme.body2.copyWith(color: themeData.accentColor);
final Widget lightThemeItem = new ListTile(
leading: new Icon(Icons.brightness_5),
title: new Text('Light'),
leading: const Icon(Icons.brightness_5),
title: const Text('Light'),
trailing: new Radio<bool>(
value: true,
groupValue: useLightTheme,
@ -141,8 +141,8 @@ class GalleryDrawer extends StatelessWidget {
);
final Widget darkThemeItem = new ListTile(
leading: new Icon(Icons.brightness_7),
title: new Text('Dark'),
leading: const Icon(Icons.brightness_7),
title: const Text('Dark'),
trailing: new Radio<bool>(
value: false,
groupValue: useLightTheme,
@ -157,7 +157,7 @@ class GalleryDrawer extends StatelessWidget {
final Widget mountainViewItem = new ListTile(
// on iOS, we don't want to show an Android phone icon
leading: new Icon(defaultTargetPlatform == TargetPlatform.iOS ? Icons.star : Icons.phone_android),
title: new Text('Android'),
title: const Text('Android'),
trailing: new Radio<TargetPlatform>(
value: TargetPlatform.android,
groupValue: Theme.of(context).platform,
@ -172,7 +172,7 @@ class GalleryDrawer extends StatelessWidget {
final Widget cupertinoItem = new ListTile(
// on iOS, we don't want to show the iPhone icon
leading: new Icon(defaultTargetPlatform == TargetPlatform.iOS ? Icons.star_border : Icons.phone_iphone),
title: new Text('iOS'),
title: const Text('iOS'),
trailing: new Radio<TargetPlatform>(
value: TargetPlatform.iOS,
groupValue: Theme.of(context).platform,
@ -185,8 +185,8 @@ class GalleryDrawer extends StatelessWidget {
);
final Widget animateSlowlyItem = new ListTile(
leading: new Icon(Icons.hourglass_empty),
title: new Text('Animate Slowly'),
leading: const Icon(Icons.hourglass_empty),
title: const Text('Animate Slowly'),
trailing: new Checkbox(
value: timeDilation != 1.0,
onChanged: (bool value) {
@ -200,8 +200,8 @@ class GalleryDrawer extends StatelessWidget {
);
final Widget sendFeedbackItem = new ListTile(
leading: new Icon(Icons.report),
title: new Text('Send feedback'),
leading: const Icon(Icons.report),
title: const Text('Send feedback'),
onTap: onSendFeedback ?? () {
UrlLauncher.launch('https://github.com/flutter/flutter/issues/new');
},
@ -266,8 +266,8 @@ class GalleryDrawer extends StatelessWidget {
if (onShowPerformanceOverlayChanged != null) {
allDrawerItems.insert(8, new ListTile(
leading: new Icon(Icons.assessment),
title: new Text('Performance Overlay'),
leading: const Icon(Icons.assessment),
title: const Text('Performance Overlay'),
trailing: new Checkbox(
value: showPerformanceOverlay,
onChanged: (bool value) {
@ -283,8 +283,8 @@ class GalleryDrawer extends StatelessWidget {
if (onCheckerboardRasterCacheImagesChanged != null) {
allDrawerItems.insert(8, new ListTile(
leading: new Icon(Icons.assessment),
title: new Text('Checkerboard Raster Cache Images'),
leading: const Icon(Icons.assessment),
title: const Text('Checkerboard Raster Cache Images'),
trailing: new Checkbox(
value: checkerboardRasterCacheImages,
onChanged: (bool value) {

View File

@ -16,7 +16,7 @@ class ButtonsDemo {
// START buttons_raised
// Create a raised button.
new RaisedButton(
child: new Text('BUTTON TITLE'),
child: const Text('BUTTON TITLE'),
onPressed: () {
// Perform some action
}
@ -26,7 +26,7 @@ new RaisedButton(
// Buttons are disabled when onPressed isn't
// specified or is null.
new RaisedButton(
child: new Text('BUTTON TITLE'),
child: const Text('BUTTON TITLE'),
onPressed: null
);
// END
@ -35,7 +35,7 @@ new RaisedButton(
// START buttons_flat
// Create a flat button.
new FlatButton(
child: new Text('BUTTON TITLE'),
child: const Text('BUTTON TITLE'),
onPressed: () {
// Perform some action
}
@ -45,7 +45,7 @@ new FlatButton(
// Buttons are disabled when onPressed isn't
// specified or is null.
new FlatButton(
child: new Text('BUTTON TITLE'),
child: const Text('BUTTON TITLE'),
onPressed: null
);
// END
@ -83,7 +83,7 @@ bool value;
// Toggleable icon button.
new IconButton(
icon: new Icon(Icons.thumb_up),
icon: const Icon(Icons.thumb_up),
onPressed: () {
setState(() => value = !value);
},
@ -96,10 +96,10 @@ new IconButton(
// Floating action button in Scaffold.
new Scaffold(
appBar: new AppBar(
title: new Text('Demo')
title: const Text('Demo')
),
floatingActionButton: new FloatingActionButton(
child: new Icon(Icons.add),
floatingActionButton: const FloatingActionButton(
child: const Icon(Icons.add),
onPressed: null
)
);

View File

@ -170,7 +170,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState
pinned: true,
expandedHeight: _kFlexibleSpaceMaxHeight,
flexibleSpace: new FlexibleSpaceBar(
title: new Text('Flutter Gallery'),
title: const Text('Flutter Gallery'),
// TODO(abarth): Wire up to the parallax in a way that doesn't pop during hero transition.
background: new _AppBarBackground(animation: kAlwaysDismissedAnimation),
),
@ -194,7 +194,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState
home,
new FadeTransition(
opacity: new CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
child: new Banner(
child: const Banner(
message: 'PREVIEW',
location: BannerLocation.topRight,
)

View File

@ -51,16 +51,16 @@ class UpdaterState extends State<Updater> {
final TextStyle dialogTextStyle =
theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
return new AlertDialog(
title: new Text('Update Flutter Gallery?'),
title: const Text('Update Flutter Gallery?'),
content: new Text('A newer version is available.', style: dialogTextStyle),
actions: <Widget>[
new FlatButton(
child: new Text('NO THANKS'),
child: const Text('NO THANKS'),
onPressed: () {
Navigator.pop(context, false);
}),
new FlatButton(
child: new Text('UPDATE'),
child: const Text('UPDATE'),
onPressed: () {
Navigator.pop(context, true);
}),

View File

@ -61,7 +61,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: new Center(
child: new Text(
'Platform button tapped $_counter time${ _counter == 1 ? '' : 's' }.',
style: new TextStyle(fontSize: 17.0))
style: const TextStyle(fontSize: 17.0))
),
),
new Container(
@ -69,7 +69,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: new Row(
children: <Widget>[
new Image.asset('assets/flutter-mark-square-64.png', scale: 1.5),
new Text('Flutter', style: new TextStyle(fontSize: 30.0)),
const Text('Flutter', style: const TextStyle(fontSize: 30.0)),
],
),
),
@ -77,7 +77,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
floatingActionButton: new FloatingActionButton(
onPressed: _sendFlutterIncrement,
child: new Icon(Icons.add),
child: const Icon(Icons.add),
),
);
}

View File

@ -4,4 +4,4 @@
import 'package:flutter/widgets.dart';
void main() => runApp(new Center(child: new Text('Hello, world!')));
void main() => runApp(const Center(child: const Text('Hello, world!')));

View File

@ -102,8 +102,8 @@ class RenderDots extends RenderBox {
void main() {
// Create some styled text to tell the user to interact with the app.
final RenderParagraph paragraph = new RenderParagraph(
new TextSpan(
style: new TextStyle(color: Colors.black87),
const TextSpan(
style: const TextStyle(color: Colors.black87),
text: "Touch me!"
)
);

View File

@ -35,7 +35,7 @@ class _LifecycleWatcherState extends State<LifecycleWatcher>
@override
Widget build(BuildContext context) {
if (_lastLifecyleState == null)
return new Text('This widget has not observed any lifecycle changes.');
return const Text('This widget has not observed any lifecycle changes.');
return new Text('The most recent lifecycle state this widget observed was: $_lastLifecyleState.');
}
}

View File

@ -46,5 +46,5 @@ class Dots extends SingleChildRenderObjectWidget {
}
void main() {
runApp(new Dots(child: new Center(child: new Text('Touch me!'))));
runApp(new Dots(child: const Center(child: const Text('Touch me!'))));
}

View File

@ -188,7 +188,7 @@ class _GestureDemoState extends State<GestureDemo> {
value: _scaleEnabled,
onChanged: (bool value) { setState(() { _scaleEnabled = value; }); }
),
new Text('Scale'),
const Text('Scale'),
]
),
new Row(
@ -197,7 +197,7 @@ class _GestureDemoState extends State<GestureDemo> {
value: _tapEnabled,
onChanged: (bool value) { setState(() { _tapEnabled = value; }); }
),
new Text('Tap'),
const Text('Tap'),
]
),
new Row(
@ -206,7 +206,7 @@ class _GestureDemoState extends State<GestureDemo> {
value: _doubleTapEnabled,
onChanged: (bool value) { setState(() { _doubleTapEnabled = value; }); }
),
new Text('Double Tap'),
const Text('Double Tap'),
]
),
new Row(
@ -215,7 +215,7 @@ class _GestureDemoState extends State<GestureDemo> {
value: _longPressEnabled,
onChanged: (bool value) { setState(() { _longPressEnabled = value; }); }
),
new Text('Long Press'),
const Text('Long Press'),
]
),
],
@ -233,7 +233,7 @@ void main() {
runApp(new MaterialApp(
theme: new ThemeData.dark(),
home: new Scaffold(
appBar: new AppBar(title: new Text('Gestures Demo')),
appBar: new AppBar(title: const Text('Gestures Demo')),
body: new GestureDemo()
)
));

View File

@ -4,4 +4,4 @@
import 'package:flutter/widgets.dart';
void main() => runApp(new Center(child: new Text('Hello, world!')));
void main() => runApp(const Center(child: const Text('Hello, world!')));

View File

@ -51,8 +51,8 @@ class AdaptedGridItem extends StatelessWidget {
new Expanded(
child: new Text(name)
),
new IconButton(
icon: new Icon(Icons.more_vert),
const IconButton(
icon: const Icon(Icons.more_vert),
onPressed: null
)
]
@ -103,7 +103,7 @@ void main() {
title: 'Media Query Example',
home: new Scaffold(
appBar: new AppBar(
title: new Text('Media Query Example')
title: const Text('Media Query Example')
),
body: new Material(child: new AdaptiveContainer(names: _kNames))
)

View File

@ -106,7 +106,7 @@ class SectorAppState extends State<SectorApp> {
margin: const EdgeInsets.only(right: 10.0),
child: new WidgetToRenderBoxAdapter(renderBox: sectorAddIcon)
),
new Text('ADD SECTOR'),
const Text('ADD SECTOR'),
]
)
)
@ -121,7 +121,7 @@ class SectorAppState extends State<SectorApp> {
margin: const EdgeInsets.only(right: 10.0),
child: new WidgetToRenderBoxAdapter(renderBox: sectorRemoveIcon)
),
new Text('REMOVE SECTOR'),
const Text('REMOVE SECTOR'),
]
)
)
@ -155,7 +155,7 @@ class SectorAppState extends State<SectorApp> {
title: 'Sector Layout',
home: new Scaffold(
appBar: new AppBar(
title: new Text('Sector Layout in a Widget Tree')
title: const Text('Sector Layout in a Widget Tree')
),
body: buildBody()
)

View File

@ -52,7 +52,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
child: new Row(
children: <Widget>[
new Image.network('https://flutter.io/images/favicon.png'),
new Text('PRESS ME'),
const Text('PRESS ME'),
]
),
onPressed: () {

View File

@ -124,7 +124,7 @@ void main() {
theme: new ThemeData.light(),
home: new Scaffold(
appBar: new AppBar(
title: new Text('Hal and Dave')
title: const Text('Hal and Dave')
),
body: new Material(
color: Colors.grey.shade50,

View File

@ -62,11 +62,11 @@ class _PlatformChannelState extends State<PlatformChannel> {
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(_batteryLevel, key: new Key('Battery level label')),
new Text(_batteryLevel, key: const Key('Battery level label')),
new Padding(
padding: new EdgeInsets.all(16.0),
padding: const EdgeInsets.all(16.0),
child: new RaisedButton(
child: new Text('Refresh'),
child: const Text('Refresh'),
onPressed: _getBatteryLevel,
),
),

View File

@ -37,10 +37,10 @@ class _PlatformChannelState extends State<PlatformChannel> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new RaisedButton(
child: new Text('Get Battery Level'),
child: const Text('Get Battery Level'),
onPressed: _getBatteryLevel,
),
new Text(_batteryLevel, key: new Key('Battery level label')),
new Text(_batteryLevel, key: const Key('Battery level label')),
],
),
),

View File

@ -20,21 +20,21 @@ class _NotImplementedDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new AlertDialog(
title: new Text('Not Implemented'),
content: new Text('This feature has not yet been implemented.'),
title: const Text('Not Implemented'),
content: const Text('This feature has not yet been implemented.'),
actions: <Widget>[
new FlatButton(
onPressed: debugDumpApp,
child: new Row(
children: <Widget>[
new Icon(
const Icon(
Icons.dvr,
size: 18.0,
),
new Container(
width: 8.0,
),
new Text('DUMP APP TO CONSOLE'),
const Text('DUMP APP TO CONSOLE'),
],
),
),
@ -42,7 +42,7 @@ class _NotImplementedDialog extends StatelessWidget {
onPressed: () {
Navigator.pop(context, false);
},
child: new Text('OH WELL'),
child: const Text('OH WELL'),
),
],
);
@ -117,20 +117,20 @@ class StockHomeState extends State<StockHome> {
return new Drawer(
child: new ListView(
children: <Widget>[
new DrawerHeader(child: new Center(child: new Text('Stocks'))),
const DrawerHeader(child: const Center(child: const Text('Stocks'))),
new ListTile(
leading: new Icon(Icons.assessment),
title: new Text('Stock List'),
leading: const Icon(Icons.assessment),
title: const Text('Stock List'),
selected: true,
),
new ListTile(
leading: new Icon(Icons.account_balance),
title: new Text('Account Balance'),
leading: const Icon(Icons.account_balance),
title: const Text('Account Balance'),
enabled: false,
),
new ListTile(
leading: new Icon(Icons.dvr),
title: new Text('Dump App to Console'),
leading: const Icon(Icons.dvr),
title: const Text('Dump App to Console'),
onTap: () {
try {
debugDumpApp();
@ -144,8 +144,8 @@ class StockHomeState extends State<StockHome> {
),
new Divider(),
new ListTile(
leading: new Icon(Icons.thumb_up),
title: new Text('Optimistic'),
leading: const Icon(Icons.thumb_up),
title: const Text('Optimistic'),
trailing: new Radio<StockMode>(
value: StockMode.optimistic,
groupValue: config.configuration.stockMode,
@ -156,8 +156,8 @@ class StockHomeState extends State<StockHome> {
},
),
new ListTile(
leading: new Icon(Icons.thumb_down),
title: new Text('Pessimistic'),
leading: const Icon(Icons.thumb_down),
title: const Text('Pessimistic'),
trailing: new Radio<StockMode>(
value: StockMode.pessimistic,
groupValue: config.configuration.stockMode,
@ -169,13 +169,13 @@ class StockHomeState extends State<StockHome> {
),
new Divider(),
new ListTile(
leading: new Icon(Icons.settings),
title: new Text('Settings'),
leading: const Icon(Icons.settings),
title: const Text('Settings'),
onTap: _handleShowSettings,
),
new ListTile(
leading: new Icon(Icons.help),
title: new Text('About'),
leading: const Icon(Icons.help),
title: const Text('About'),
onTap: _handleShowAbout,
),
],
@ -197,7 +197,7 @@ class StockHomeState extends State<StockHome> {
title: new Text(StockStrings.of(context).title()),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.search),
icon: const Icon(Icons.search),
onPressed: _handleSearchBegin,
tooltip: 'Search',
),
@ -207,19 +207,19 @@ class StockHomeState extends State<StockHome> {
new CheckedPopupMenuItem<_StockMenuItem>(
value: _StockMenuItem.autorefresh,
checked: _autorefresh,
child: new Text('Autorefresh'),
child: const Text('Autorefresh'),
),
new PopupMenuItem<_StockMenuItem>(
value: _StockMenuItem.refresh,
child: new Text('Refresh'),
child: const Text('Refresh'),
),
new PopupMenuItem<_StockMenuItem>(
value: _StockMenuItem.speedUp,
child: new Text('Increase animation speed'),
child: const Text('Increase animation speed'),
),
new PopupMenuItem<_StockMenuItem>(
value: _StockMenuItem.speedDown,
child: new Text('Decrease animation speed'),
child: const Text('Decrease animation speed'),
),
],
),
@ -287,7 +287,7 @@ class StockHomeState extends State<StockHome> {
Widget buildSearchBar() {
return new AppBar(
leading: new IconButton(
icon: new Icon(Icons.arrow_back),
icon: const Icon(Icons.arrow_back),
color: Theme.of(context).accentColor,
onPressed: _handleSearchEnd,
tooltip: 'Back',
@ -313,7 +313,7 @@ class StockHomeState extends State<StockHome> {
Widget buildFloatingActionButton() {
return new FloatingActionButton(
tooltip: 'Create company',
child: new Icon(Icons.add),
child: const Icon(Icons.add),
backgroundColor: Colors.redAccent,
onPressed: _handleCreateCompany,
);

View File

@ -68,17 +68,17 @@ class StockSettingsState extends State<StockSettings> {
showDialog<bool>(
context: context,
child: new AlertDialog(
title: new Text("Change mode?"),
content: new Text("Optimistic mode means everything is awesome. Are you sure you can handle that?"),
title: const Text("Change mode?"),
content: const Text("Optimistic mode means everything is awesome. Are you sure you can handle that?"),
actions: <Widget>[
new FlatButton(
child: new Text('NO THANKS'),
child: const Text('NO THANKS'),
onPressed: () {
Navigator.pop(context, false);
}
),
new FlatButton(
child: new Text('AGREE'),
child: const Text('AGREE'),
onPressed: () {
Navigator.pop(context, true);
}
@ -97,15 +97,15 @@ class StockSettingsState extends State<StockSettings> {
Widget buildAppBar(BuildContext context) {
return new AppBar(
title: new Text('Settings')
title: const Text('Settings')
);
}
Widget buildSettingsPane(BuildContext context) {
final List<Widget> rows = <Widget>[
new ListTile(
leading: new Icon(Icons.thumb_up),
title: new Text('Everything is awesome'),
leading: const Icon(Icons.thumb_up),
title: const Text('Everything is awesome'),
onTap: _confirmOptimismChange,
trailing: new Checkbox(
value: config.configuration.stockMode == StockMode.optimistic,
@ -113,8 +113,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.backup),
title: new Text('Back up stock list to the cloud'),
leading: const Icon(Icons.backup),
title: const Text('Back up stock list to the cloud'),
onTap: () { _handleBackupChanged(!(config.configuration.backupMode == BackupMode.enabled)); },
trailing: new Switch(
value: config.configuration.backupMode == BackupMode.enabled,
@ -122,8 +122,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.picture_in_picture),
title: new Text('Show rendering performance overlay'),
leading: const Icon(Icons.picture_in_picture),
title: const Text('Show rendering performance overlay'),
onTap: () { _handleShowPerformanceOverlayChanged(!config.configuration.showPerformanceOverlay); },
trailing: new Switch(
value: config.configuration.showPerformanceOverlay,
@ -131,8 +131,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.accessibility),
title: new Text('Show semantics overlay'),
leading: const Icon(Icons.accessibility),
title: const Text('Show semantics overlay'),
onTap: () { _handleShowSemanticsDebuggerChanged(!config.configuration.showSemanticsDebugger); },
trailing: new Switch(
value: config.configuration.showSemanticsDebugger,
@ -144,8 +144,8 @@ class StockSettingsState extends State<StockSettings> {
// material grid and size construction lines are only available in checked mode
rows.addAll(<Widget>[
new ListTile(
leading: new Icon(Icons.border_clear),
title: new Text('Show material grid (for debugging)'),
leading: const Icon(Icons.border_clear),
title: const Text('Show material grid (for debugging)'),
onTap: () { _handleShowGridChanged(!config.configuration.debugShowGrid); },
trailing: new Switch(
value: config.configuration.debugShowGrid,
@ -153,8 +153,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.border_all),
title: new Text('Show construction lines (for debugging)'),
leading: const Icon(Icons.border_all),
title: const Text('Show construction lines (for debugging)'),
onTap: () { _handleShowSizesChanged(!config.configuration.debugShowSizes); },
trailing: new Switch(
value: config.configuration.debugShowSizes,
@ -162,8 +162,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.format_color_text),
title: new Text('Show baselines (for debugging)'),
leading: const Icon(Icons.format_color_text),
title: const Text('Show baselines (for debugging)'),
onTap: () { _handleShowBaselinesChanged(!config.configuration.debugShowBaselines); },
trailing: new Switch(
value: config.configuration.debugShowBaselines,
@ -171,8 +171,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.filter_none),
title: new Text('Show layer boundaries (for debugging)'),
leading: const Icon(Icons.filter_none),
title: const Text('Show layer boundaries (for debugging)'),
onTap: () { _handleShowLayersChanged(!config.configuration.debugShowLayers); },
trailing: new Switch(
value: config.configuration.debugShowLayers,
@ -180,8 +180,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.mouse),
title: new Text('Show pointer hit-testing (for debugging)'),
leading: const Icon(Icons.mouse),
title: const Text('Show pointer hit-testing (for debugging)'),
onTap: () { _handleShowPointersChanged(!config.configuration.debugShowPointers); },
trailing: new Switch(
value: config.configuration.debugShowPointers,
@ -189,8 +189,8 @@ class StockSettingsState extends State<StockSettings> {
),
),
new ListTile(
leading: new Icon(Icons.gradient),
title: new Text('Show repaint rainbow (for debugging)'),
leading: const Icon(Icons.gradient),
title: const Text('Show repaint rainbow (for debugging)'),
onTap: () { _handleShowRainbowChanged(!config.configuration.debugShowRainbow); },
trailing: new Switch(
value: config.configuration.debugShowRainbow,

View File

@ -100,8 +100,8 @@ class StockSymbolBottomSheet extends StatelessWidget {
Widget build(BuildContext context) {
return new Container(
padding: const EdgeInsets.all(10.0),
decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26))
decoration: const BoxDecoration(
border: const Border(top: const BorderSide(color: Colors.black26))
),
child: new _StockSymbolView(
stock: stock,

View File

@ -290,7 +290,7 @@ class AboutDialog extends StatelessWidget {
),
actions: <Widget>[
new FlatButton(
child: new Text('VIEW LICENSES'),
child: const Text('VIEW LICENSES'),
onPressed: () {
showLicensePage(
context: context,
@ -302,7 +302,7 @@ class AboutDialog extends StatelessWidget {
}
),
new FlatButton(
child: new Text('CLOSE'),
child: const Text('CLOSE'),
onPressed: () {
Navigator.pop(context);
}
@ -377,9 +377,9 @@ class _LicensePageState extends State<LicensePage> {
if (!mounted)
return;
setState(() {
_licenses.add(new Padding(
_licenses.add(const Padding(
padding: const EdgeInsets.symmetric(vertical: 18.0),
child: new Text(
child: const Text(
'🍀‬', // That's U+1F340. Could also use U+2766 (❦) if U+1F340 doesn't work everywhere.
textAlign: TextAlign.center
)
@ -443,7 +443,7 @@ class _LicensePageState extends State<LicensePage> {
}
return new Scaffold(
appBar: new AppBar(
title: new Text('Licenses')
title: const Text('Licenses')
),
body: new DefaultTextStyle(
style: Theme.of(context).textTheme.caption,

View File

@ -450,7 +450,7 @@ class DataTable extends StatelessWidget {
}) {
final bool isLightTheme = Theme.of(context).brightness == Brightness.light;
if (showEditIcon) {
final Widget icon = new Icon(Icons.edit, size: 18.0);
final Widget icon = const Icon(Icons.edit, size: 18.0);
label = new Expanded(child: label);
label = new Row(children: numeric ? <Widget>[ icon, label ] : <Widget>[ label, icon ]);
}
@ -523,7 +523,7 @@ class DataTable extends StatelessWidget {
int displayColumnIndex = 0;
if (showCheckboxColumn) {
tableColumns[0] = new FixedColumnWidth(_kTablePadding + Checkbox.width + _kTablePadding / 2.0);
tableColumns[0] = const FixedColumnWidth(_kTablePadding + Checkbox.width + _kTablePadding / 2.0);
tableRows[0].children[0] = _buildCheckbox(
color: theme.accentColor,
checked: allChecked,

View File

@ -677,11 +677,11 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: new Text('CANCEL'),
child: const Text('CANCEL'),
onPressed: _handleCancel,
),
new FlatButton(
child: new Text('OK'),
child: const Text('OK'),
onPressed: _handleOk,
),
],

View File

@ -107,7 +107,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
onPressed: config.onPressed == null ? null : _handlePressed,
icon: new RotationTransition(
turns: _iconTurns,
child: new Icon(Icons.expand_more)
child: const Icon(Icons.expand_more)
)
);
}

View File

@ -305,7 +305,7 @@ class InputDecorator extends StatelessWidget {
if (decoration.hideDivider) {
return new Container(
margin: margin + new EdgeInsets.only(bottom: bottomBorder),
margin: margin + const EdgeInsets.only(bottom: bottomBorder),
padding: padding,
child: child,
);

View File

@ -106,7 +106,7 @@ class ListTileTheme extends InheritedWidget {
/// ```
static ListTileTheme of(BuildContext context) {
final ListTileTheme result = context.inheritFromWidgetOfExactType(ListTileTheme);
return result ?? new ListTileTheme();
return result ?? const ListTileTheme();
}
@override

View File

@ -298,7 +298,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
}
} else if (_selectedRowCount == 1) {
// TODO(ianh): Real l10n.
headerWidgets.add(new Expanded(child: new Text('1 item selected')));
headerWidgets.add(const Expanded(child: const Text('1 item selected')));
} else {
headerWidgets.add(new Expanded(child: new Text('$_selectedRowCount items selected')));
}
@ -328,7 +328,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
})
.toList();
footerWidgets.addAll(<Widget>[
new Text('Rows per page:'),
const Text('Rows per page:'),
new DropdownButtonHideUnderline(
child: new DropdownButton<int>(
items: availableRowsPerPage,
@ -347,7 +347,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
),
new Container(width: 32.0),
new IconButton(
icon: new Icon(Icons.chevron_left),
icon: const Icon(Icons.chevron_left),
padding: EdgeInsets.zero,
tooltip: 'Previous page',
onPressed: _firstRowIndex <= 0 ? null : () {
@ -356,7 +356,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
),
new Container(width: 24.0),
new IconButton(
icon: new Icon(Icons.chevron_right),
icon: const Icon(Icons.chevron_right),
padding: EdgeInsets.zero,
tooltip: 'Next page',
onPressed: (!_rowCountApproximate && (_firstRowIndex + config.rowsPerPage >= _rowCount)) ? null : () {

View File

@ -547,7 +547,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
Widget build(BuildContext context) {
if (config.child == null) {
return new IconButton(
icon: new Icon(Icons.more_vert),
icon: const Icon(Icons.more_vert),
padding: config.padding,
tooltip: config.tooltip,
onPressed: showButtonMenu,

View File

@ -249,7 +249,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
color: isDarkActive ? _kCircleActiveDark : _kCircleActiveLight,
);
case StepState.error:
return new Text('!', style: _kStepStyle);
return const Text('!', style: _kStepStyle);
}
return null;
}
@ -351,7 +351,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
color: _isDark() ? themeData.backgroundColor : themeData.primaryColor,
textColor: Colors.white,
textTheme: ButtonTextTheme.normal,
child: new Text('CONTINUE'),
child: const Text('CONTINUE'),
),
new Container(
margin: const EdgeInsets.only(left: 8.0),
@ -359,7 +359,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
onPressed: config.onStepCancel,
textColor: cancelColor,
textTheme: ButtonTextTheme.normal,
child: new Text('CANCEL'),
child: const Text('CANCEL'),
),
),
],

View File

@ -27,17 +27,17 @@ class _TextSelectionToolbar extends StatelessWidget {
final List<Widget> items = <Widget>[];
if (!value.selection.isCollapsed) {
items.add(new FlatButton(child: new Text('CUT'), onPressed: _handleCut));
items.add(new FlatButton(child: new Text('COPY'), onPressed: _handleCopy));
items.add(new FlatButton(child: const Text('CUT'), onPressed: _handleCut));
items.add(new FlatButton(child: const Text('COPY'), onPressed: _handleCopy));
}
items.add(new FlatButton(
child: new Text('PASTE'),
child: const Text('PASTE'),
// TODO(mpcomplete): This should probably be grayed-out if there is nothing to paste.
onPressed: _handlePaste
));
if (value.text.isNotEmpty) {
if (value.selection.isCollapsed)
items.add(new FlatButton(child: new Text('SELECT ALL'), onPressed: _handleSelectAll));
items.add(new FlatButton(child: const Text('SELECT ALL'), onPressed: _handleSelectAll));
}
return new Material(

View File

@ -702,11 +702,11 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
child: new ButtonBar(
children: <Widget>[
new FlatButton(
child: new Text('CANCEL'),
child: const Text('CANCEL'),
onPressed: _handleCancel
),
new FlatButton(
child: new Text('OK'),
child: const Text('OK'),
onPressed: _handleOk
),
]

View File

@ -213,7 +213,7 @@ class _TwoLevelSublistState extends State<TwoLevelSublist> with SingleTickerProv
),
trailing: new RotationTransition(
turns: _iconTurns,
child: new Icon(Icons.expand_more)
child: const Icon(Icons.expand_more)
)
)
),

View File

@ -21,15 +21,14 @@ class DecoratedBox extends SingleChildRenderObjectWidget {
///
/// The [decoration] and [position] arguments must not be null. By default the
/// decoration paints behind the child.
DecoratedBox({
const DecoratedBox({
Key key,
@required this.decoration,
this.position: DecorationPosition.background,
Widget child
}) : super(key: key, child: child) {
assert(decoration != null);
assert(position != null);
}
}) : assert(decoration != null),
assert(position != null),
super(key: key, child: child);
/// What decoration to paint.
///

View File

@ -14,7 +14,7 @@ class DefaultTextStyle extends InheritedWidget {
///
/// Consider using [DefaultTextStyle.merge] to inherit styling information
/// from the current default text style for a given [BuildContext].
DefaultTextStyle({
const DefaultTextStyle({
Key key,
@required this.style,
this.textAlign,
@ -22,12 +22,11 @@ class DefaultTextStyle extends InheritedWidget {
this.overflow: TextOverflow.clip,
this.maxLines,
@required Widget child,
}) : super(key: key, child: child) {
assert(style != null);
assert(softWrap != null);
assert(overflow != null);
assert(child != null);
}
}) : assert(style != null),
assert(softWrap != null),
assert(overflow != null),
assert(child != null),
super(key: key, child: child);
/// A const-constructible default text style that provides fallback values.
///
@ -140,7 +139,7 @@ class Text extends StatelessWidget {
///
/// If the [style] argument is null, the text will use the style from the
/// closest enclosing [DefaultTextStyle].
Text(this.data, {
const Text(this.data, {
Key key,
this.style,
this.textAlign,
@ -148,9 +147,8 @@ class Text extends StatelessWidget {
this.overflow,
this.textScaleFactor,
this.maxLines,
}) : super(key: key) {
assert(data != null);
}
}) : assert(data != null),
super(key: key);
/// The text to display.
final String data;

View File

@ -16,7 +16,7 @@ void main() {
testWidgets('Default layout minimum size', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(child: new CupertinoButton(
child: new Text('X', style: testStyle),
child: const Text('X', style: testStyle),
onPressed: null,
))
);
@ -32,7 +32,7 @@ void main() {
final double minSize = 60.0;
await tester.pumpWidget(
new Center(child: new CupertinoButton(
child: new Text('X', style: testStyle),
child: const Text('X', style: testStyle),
onPressed: null,
minSize: minSize,
))
@ -48,7 +48,7 @@ void main() {
testWidgets('Size grows with text', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(child: new CupertinoButton(
child: new Text('XXXX', style: testStyle),
child: const Text('XXXX', style: testStyle),
onPressed: null,
))
);
@ -62,7 +62,7 @@ void main() {
testWidgets('Button with background is wider', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new CupertinoButton(
child: new Text('X', style: testStyle),
child: const Text('X', style: testStyle),
onPressed: null,
color: const Color(0xFFFFFFFF),
)));
@ -76,7 +76,7 @@ void main() {
testWidgets('Custom padding', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new CupertinoButton(
child: new Text(' ', style: testStyle),
child: const Text(' ', style: testStyle),
onPressed: null,
padding: const EdgeInsets.all(100.0),
)));
@ -94,7 +94,7 @@ void main() {
builder: (BuildContext context, StateSetter setState) {
return new Center(
child: new CupertinoButton(
child: new Text('Tap me'),
child: const Text('Tap me'),
onPressed: () {
setState(() {
value = true;
@ -117,7 +117,7 @@ void main() {
testWidgets('Disabled button doesn\'t animate', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new CupertinoButton(
child: new Text('Tap me'),
child: const Text('Tap me'),
onPressed: null,
)));
expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
@ -128,7 +128,7 @@ void main() {
testWidgets('pressedOpacity defaults to 0.1', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new CupertinoButton(
child: new Text('Tap me'),
child: const Text('Tap me'),
onPressed: () { },
)));
@ -149,7 +149,7 @@ void main() {
final double pressedOpacity = 0.5;
await tester.pumpWidget(new Center(child: new CupertinoButton(
pressedOpacity: pressedOpacity,
child: new Text('Tap me'),
child: const Text('Tap me'),
onPressed: () { },
)));

View File

@ -20,11 +20,11 @@ void main() {
showDialog<Null>(
context: context,
child: new CupertinoAlertDialog(
title: new Text('The title'),
content: new Text('The content'),
title: const Text('The title'),
content: const Text('The content'),
actions: <Widget>[
new CupertinoDialogAction(
child: new Text('Cancel'),
child: const Text('Cancel'),
),
new CupertinoDialogAction(
isDestructive: true,
@ -32,13 +32,13 @@ void main() {
didDelete = true;
Navigator.pop(context);
},
child: new Text('Delete'),
child: const Text('Delete'),
),
],
),
);
},
child: new Text('Go'),
child: const Text('Go'),
);
},
),
@ -66,7 +66,7 @@ void main() {
testWidgets('Dialog action styles', (WidgetTester tester) async {
await tester.pumpWidget(new CupertinoDialogAction(
isDestructive: true,
child: new Text('Ok'),
child: const Text('Ok'),
));
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));

View File

@ -199,7 +199,7 @@ Future<Null> main() async {
test('Error reporting - NoSuchMethodError', () async {
expect(console, isEmpty);
FlutterError.dumpErrorToConsole(new FlutterErrorDetails(
FlutterError.dumpErrorToConsole(const FlutterErrorDetails(
exception: 'hello',
));
expect(console.join('\n'), matches(new RegExp(
@ -209,7 +209,7 @@ Future<Null> main() async {
'════════════════════════════════════════════════════════════════════════════════════════════════════\$',
)));
console.clear();
FlutterError.dumpErrorToConsole(new FlutterErrorDetails(
FlutterError.dumpErrorToConsole(const FlutterErrorDetails(
exception: 'hello again',
));
expect(console.join('\n'), 'Another exception was thrown: hello again');

View File

@ -15,7 +15,7 @@ void main() {
title: 'Pirate app',
home: new Scaffold(
appBar: new AppBar(
title: new Text('Home'),
title: const Text('Home'),
),
drawer: new Drawer(
child: new ListView(
@ -25,7 +25,7 @@ void main() {
applicationIcon: const FlutterLogo(),
applicationLegalese: 'I am the very model of a modern major general.',
aboutBoxChildren: <Widget>[
new Text('About box'),
const Text('About box'),
]
),
],
@ -89,7 +89,7 @@ void main() {
]);
});
await tester.pumpWidget(new Center(
await tester.pumpWidget(const Center(
child: const LicensePage()
));

View File

@ -15,7 +15,7 @@ Widget buildSliverAppBarApp({ bool floating, bool pinned, double expandedHeight
primary: true,
slivers: <Widget>[
new SliverAppBar(
title: new Text('AppBar Title'),
title: const Text('AppBar Title'),
floating: floating,
pinned: pinned,
expandedHeight: expandedHeight,
@ -63,7 +63,7 @@ void main() {
theme: new ThemeData(platform: TargetPlatform.android),
home: new Scaffold(
appBar: new AppBar(
title: new Text('X'),
title: const Text('X'),
),
),
),
@ -82,7 +82,7 @@ void main() {
theme: new ThemeData(platform: TargetPlatform.iOS),
home: new Scaffold(
appBar: new AppBar(
title: new Text('X'),
title: const Text('X'),
),
),
),
@ -101,7 +101,7 @@ void main() {
home: new Scaffold(
appBar: new AppBar(
centerTitle: true,
title: new Text('X'),
title: const Text('X'),
)
)
)
@ -121,7 +121,7 @@ void main() {
home: new Scaffold(
appBar: new AppBar(
centerTitle: false,
title: new Text('X'),
title: const Text('X'),
),
),
),
@ -138,7 +138,7 @@ void main() {
home: new Scaffold(
appBar: new AppBar(
centerTitle: false,
title: new Text('X'),
title: const Text('X'),
),
// A drawer causes a leading hamburger.
drawer: new Drawer(),
@ -254,9 +254,9 @@ void main() {
new SizedBox(
height: kToolbarHeight,
child: new AppBar(
leading: new Text('L'),
title: new Text('No Scaffold'),
actions: <Widget>[new Text('A1'), new Text('A2')],
leading: const Text('L'),
title: const Text('No Scaffold'),
actions: <Widget>[const Text('A1'), const Text('A2')],
),
),
);
@ -276,7 +276,7 @@ void main() {
width: 0.0,
child: new Scaffold(
appBar: new AppBar(
title: new Text('X'),
title: const Text('X'),
),
),
),
@ -325,7 +325,7 @@ void main() {
theme: new ThemeData(platform: TargetPlatform.android),
home: new Scaffold(
appBar: new AppBar(
title: new Text('X'),
title: const Text('X'),
),
drawer: new Column(), // Doesn't really matter. Triggers a hamburger regardless.
),
@ -343,16 +343,16 @@ void main() {
theme: new ThemeData(platform: TargetPlatform.android),
home: new Scaffold(
appBar: new AppBar(
title: new Text('X'),
title: const Text('X'),
actions: <Widget> [
new IconButton(
icon: new Icon(Icons.share),
const IconButton(
icon: const Icon(Icons.share),
onPressed: null,
tooltip: 'Share',
iconSize: 20.0,
),
new IconButton(
icon: new Icon(Icons.add),
const IconButton(
icon: const Icon(Icons.add),
onPressed: null,
tooltip: 'Add',
iconSize: 60.0,

View File

@ -30,7 +30,7 @@ void main() {
await tester.pumpWidget(
new MaterialApp(
home: new MaterialApp(
home: new Text('Home sweet home'),
home: const Text('Home sweet home'),
),
),
);
@ -58,7 +58,7 @@ void main() {
autofocus: true,
node: focusScopeNode,
child: new MaterialApp(
home: new Text('Home'),
home: const Text('Home'),
),
));
@ -95,7 +95,7 @@ void main() {
builder: (BuildContext context) {
return new Material(
child: new RaisedButton(
child: new Text('X'),
child: const Text('X'),
onPressed: () { Navigator.of(context).pushNamed('/next'); },
),
);
@ -132,7 +132,7 @@ void main() {
});
testWidgets('Cannot pop the initial route', (WidgetTester tester) async {
await tester.pumpWidget(new MaterialApp(home: new Text('Home')));
await tester.pumpWidget(new MaterialApp(home: const Text('Home')));
expect(find.text('Home'), findsOneWidget);

View File

@ -9,11 +9,11 @@ void main() {
testWidgets('BackButton control test', (WidgetTester tester) async {
await tester.pumpWidget(
new MaterialApp(
home: new Material(child: new Text('Home')),
home: new Material(child: const Text('Home')),
routes: <String, WidgetBuilder>{
'/next': (BuildContext context) {
return new Material(
child: new Center(
child: const Center(
child: const BackButton(),
)
);

View File

@ -14,12 +14,12 @@ void main() {
bottomNavigationBar: new BottomNavigationBar(
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.ac_unit),
title: new Text('AC')
icon: const Icon(Icons.ac_unit),
title: const Text('AC')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm')
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm')
)
],
onTap: (int index) {
@ -40,12 +40,12 @@ void main() {
bottomNavigationBar: new BottomNavigationBar(
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.ac_unit),
title: new Text('AC')
icon: const Icon(Icons.ac_unit),
title: const Text('AC')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm')
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm')
)
]
)
@ -65,12 +65,12 @@ void main() {
type: BottomNavigationBarType.shifting,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.ac_unit),
title: new Text('AC')
icon: const Icon(Icons.ac_unit),
title: const Text('AC')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm')
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm')
)
]
)
@ -89,12 +89,12 @@ void main() {
type: BottomNavigationBarType.shifting,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.ac_unit),
title: new Text('AC')
icon: const Icon(Icons.ac_unit),
title: const Text('AC')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm')
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm')
)
]
)
@ -116,20 +116,20 @@ void main() {
type: BottomNavigationBarType.shifting,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.ac_unit),
title: new Text('AC')
icon: const Icon(Icons.ac_unit),
title: const Text('AC')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm')
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_time),
title: new Text('Time')
icon: const Icon(Icons.access_time),
title: const Text('Time')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.add),
title: new Text('Add')
icon: const Icon(Icons.add),
title: const Text('Add')
)
]
)
@ -176,20 +176,20 @@ void main() {
type: BottomNavigationBarType.shifting,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.ac_unit),
title: new Text('AC')
icon: const Icon(Icons.ac_unit),
title: const Text('AC')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm')
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_time),
title: new Text('Time')
icon: const Icon(Icons.access_time),
title: const Text('Time')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.add),
title: new Text('Add')
icon: const Icon(Icons.add),
title: const Text('Add')
)
]
)
@ -214,20 +214,20 @@ void main() {
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.ac_unit),
title: new Text('AC')
icon: const Icon(Icons.ac_unit),
title: const Text('AC')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_alarm),
title: new Text('Alarm')
icon: const Icon(Icons.access_alarm),
title: const Text('Alarm')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.access_time),
title: new Text('Time')
icon: const Icon(Icons.access_time),
title: const Text('Time')
),
new BottomNavigationBarItem(
icon: new Icon(Icons.add),
title: new Text('Add')
icon: const Icon(Icons.add),
title: const Text('Add')
)
]
)
@ -249,11 +249,11 @@ void main() {
iconSize: 12.0,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
title: new Text('A'),
icon: new Icon(Icons.ac_unit),
title: const Text('A'),
icon: const Icon(Icons.ac_unit),
),
new BottomNavigationBarItem(
title: new Text('B'),
title: const Text('B'),
icon: new Builder(
builder: (BuildContext context) {
builderIconSize = IconTheme.of(context).size;

View File

@ -18,7 +18,7 @@ void main() {
child: new Center(
child: new FlatButton(
onPressed: () { },
child: new Text('ABC')
child: const Text('ABC')
)
)
)
@ -43,8 +43,8 @@ void main() {
});
testWidgets('Does button highlight + splash colors work if set directly', (WidgetTester tester) async {
final Color directSplashColor = new Color(0xFF000011);
final Color directHighlightColor = new Color(0xFF000011);
final Color directSplashColor = const Color(0xFF000011);
final Color directHighlightColor = const Color(0xFF000011);
Widget buttonWidget = new Material(
child: new Center(
@ -66,7 +66,7 @@ void main() {
final Point center = tester.getCenter(find.byType(MaterialButton));
final TestGesture gesture = await tester.startGesture(center);
await tester.pump(); // start gesture
await tester.pump(new Duration(milliseconds: 200)); // wait for splash to be well under way
await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way
expect(
Material.of(tester.element(find.byType(MaterialButton))),
@ -75,8 +75,8 @@ void main() {
..rrect(color: directHighlightColor)
);
final Color themeSplashColor1 = new Color(0xFF001100);
final Color themeHighlightColor1 = new Color(0xFF001100);
final Color themeSplashColor1 = const Color(0xFF001100);
final Color themeHighlightColor1 = const Color(0xFF001100);
buttonWidget = new Material(
child: new Center(
@ -103,8 +103,8 @@ void main() {
..rrect(color: themeHighlightColor1)
);
final Color themeSplashColor2 = new Color(0xFF002200);
final Color themeHighlightColor2 = new Color(0xFF002200);
final Color themeSplashColor2 = const Color(0xFF002200);
final Color themeHighlightColor2 = const Color(0xFF002200);
await tester.pumpWidget(
new Theme(

View File

@ -14,9 +14,9 @@ void main() {
child: new Center(
child: new Chip(
avatar: new CircleAvatar(
child: new Text('C')
child: const Text('C')
),
label: new Text('Chip'),
label: const Text('Chip'),
onDeleted: () {
didDeleteChip = true;
}

View File

@ -14,7 +14,7 @@ void main() {
child: new CircleAvatar(
backgroundColor: backgroundColor,
radius: 50.0,
child: new Text('Z'),
child: const Text('Z'),
),
),
);
@ -36,7 +36,7 @@ void main() {
new Center(
child: new CircleAvatar(
foregroundColor: foregroundColor,
child: new Text('Z'),
child: const Text('Z'),
),
),
);
@ -64,7 +64,7 @@ void main() {
data: theme,
child: new Center(
child: new CircleAvatar(
child: new Text('Z'),
child: const Text('Z'),
),
),
),

View File

@ -11,7 +11,7 @@ const List<int> accentKeys = const <int>[100, 200, 400, 700];
void main() {
test('MaterialColor basic functionality', () {
final MaterialColor color = new MaterialColor(
final MaterialColor color = const MaterialColor(
500,
const <int, Color>{
50: const Color(50),

View File

@ -19,12 +19,12 @@ void main() {
log.add('select-all: $value');
},
columns: <DataColumn>[
new DataColumn(
label: new Text('Name'),
const DataColumn(
label: const Text('Name'),
tooltip: 'Name',
),
new DataColumn(
label: new Text('Calories'),
label: const Text('Calories'),
tooltip: 'Calories',
numeric: true,
onSort: (int columnIndex, bool ascending) {

View File

@ -127,7 +127,7 @@ void main() {
onPressed: () {
buttonContext = context;
},
child: new Text('Go'),
child: const Text('Go'),
);
},
),

View File

@ -9,7 +9,7 @@ void main() {
testWidgets('debugCheckHasMaterial control test', (WidgetTester tester) async {
await tester.pumpWidget(new FlatButton(
onPressed: null,
child: new Text('Go'),
child: const Text('Go'),
));
expect(tester.takeException(), isFlutterError);
});

View File

@ -16,7 +16,7 @@ void main() {
builder: (BuildContext context) {
return new Center(
child: new RaisedButton(
child: new Text('X'),
child: const Text('X'),
onPressed: () {
showDialog<Null>(
context: context,
@ -33,7 +33,7 @@ void main() {
onPressed: () {
didPressOk = true;
},
child: new Text('OK')
child: const Text('OK')
)
]
)
@ -66,13 +66,13 @@ void main() {
builder: (BuildContext context) {
return new Center(
child: new RaisedButton(
child: new Text('X'),
child: const Text('X'),
onPressed: () {
showDialog<Null>(
context: context,
child: new AlertDialog(
title: new Text('Title'),
content: new Text('Y'),
title: const Text('Title'),
content: const Text('Y'),
actions: <Widget>[ ],
),
);
@ -104,7 +104,7 @@ void main() {
child: new Center(
child: new RaisedButton(
onPressed: null,
child: new Text('Go'),
child: const Text('Go'),
),
),
),
@ -116,16 +116,16 @@ void main() {
final Future<int> result = showDialog(
context: context,
child: new SimpleDialog(
title: new Text('Title'),
title: const Text('Title'),
children: <Widget>[
new SimpleDialogOption(
onPressed: () {
Navigator.pop(context, 42);
},
child: new Text('First option'),
child: const Text('First option'),
),
new SimpleDialogOption(
child: new Text('Second option'),
child: const Text('Second option'),
),
],
),
@ -145,7 +145,7 @@ void main() {
child: new Center(
child: new RaisedButton(
onPressed: null,
child: new Text('Go'),
child: const Text('Go'),
),
),
),
@ -160,7 +160,7 @@ void main() {
width: 100.0,
height: 100.0,
alignment: FractionalOffset.center,
child: new Text('Dialog1'),
child: const Text('Dialog1'),
),
);
@ -180,7 +180,7 @@ void main() {
width: 100.0,
height: 100.0,
alignment: FractionalOffset.center,
child: new Text('Dialog2'),
child: const Text('Dialog2'),
),
);

Some files were not shown because too many files have changed in this diff Show More