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

@@ -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,