prefer const constructors (#8316)
This commit is contained in:
committed by
Adam Barth
parent
663862557b
commit
e9a775bf38
@@ -90,7 +90,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
|
||||
Widget buildRaisedButton() {
|
||||
return new Align(
|
||||
alignment: new FractionalOffset(0.5, 0.4),
|
||||
alignment: const FractionalOffset(0.5, 0.4),
|
||||
child: new ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
@@ -111,7 +111,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
|
||||
Widget buildFlatButton() {
|
||||
return new Align(
|
||||
alignment: new FractionalOffset(0.5, 0.4),
|
||||
alignment: const FractionalOffset(0.5, 0.4),
|
||||
child: new ButtonBar(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
@@ -158,7 +158,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
new SizedBox(
|
||||
const SizedBox(
|
||||
height: 24.0,
|
||||
),
|
||||
new ListItem(
|
||||
@@ -179,7 +179,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
new SizedBox(
|
||||
const SizedBox(
|
||||
height: 24.0,
|
||||
),
|
||||
new ListItem(
|
||||
@@ -213,7 +213,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
|
||||
Widget buildIconButton() {
|
||||
return new Align(
|
||||
alignment: new FractionalOffset(0.5, 0.4),
|
||||
alignment: const FractionalOffset(0.5, 0.4),
|
||||
child: new Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
@@ -237,7 +237,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
|
||||
Widget buildActionButton() {
|
||||
return new Align(
|
||||
alignment: new FractionalOffset(0.5, 0.4),
|
||||
alignment: const FractionalOffset(0.5, 0.4),
|
||||
child: new FloatingActionButton(
|
||||
child: new Icon(Icons.add),
|
||||
onPressed: () {
|
||||
|
||||
@@ -95,7 +95,7 @@ class _DateTimePicker extends StatelessWidget {
|
||||
onPressed: () { _selectDate(context); },
|
||||
),
|
||||
),
|
||||
new SizedBox(width: 12.0),
|
||||
const SizedBox(width: 12.0),
|
||||
new Expanded(
|
||||
flex: 3,
|
||||
child: new _InputDropdown(
|
||||
|
||||
@@ -122,7 +122,7 @@ class IconsDemoState extends State<IconsDemo> {
|
||||
new Expanded(
|
||||
child: new Center(
|
||||
child: new IconTheme(
|
||||
data: new IconThemeData(opacity: 1.0),
|
||||
data: const IconThemeData(opacity: 1.0),
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
|
||||
@@ -26,7 +26,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
|
||||
|
||||
Future<Null> _handleRefresh() {
|
||||
Completer<Null> completer = new Completer<Null>();
|
||||
new Timer(new Duration(seconds: 3), () { completer.complete(null); });
|
||||
new Timer(const Duration(seconds: 3), () { completer.complete(null); });
|
||||
return completer.future.then((_) {
|
||||
_scaffoldKey.currentState?.showSnackBar(new SnackBar(
|
||||
content: new Text("Refresh complete"),
|
||||
|
||||
@@ -140,7 +140,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
return new SliverPadding(
|
||||
padding: padding,
|
||||
child: new SliverGrid(
|
||||
gridDelegate: new SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: _kRecipePageMaxWidth,
|
||||
crossAxisSpacing: 8.0,
|
||||
mainAxisSpacing: 8.0,
|
||||
@@ -299,7 +299,7 @@ class RecipePage extends StatefulWidget {
|
||||
|
||||
class _RecipePageState extends State<RecipePage> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final TextStyle menuItemStyle = new PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0);
|
||||
final TextStyle menuItemStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0);
|
||||
|
||||
double _getAppBarHeight(BuildContext context) => MediaQuery.of(context).size.height * 0.3;
|
||||
|
||||
@@ -448,7 +448,7 @@ class RecipeSheet extends StatelessWidget {
|
||||
),
|
||||
new TableRow(
|
||||
children: <Widget>[
|
||||
new SizedBox(),
|
||||
const SizedBox(),
|
||||
new Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, bottom: 4.0),
|
||||
child: new Text(recipe.description, style: descriptionStyle)
|
||||
@@ -457,7 +457,7 @@ class RecipeSheet extends StatelessWidget {
|
||||
),
|
||||
new TableRow(
|
||||
children: <Widget>[
|
||||
new SizedBox(),
|
||||
const SizedBox(),
|
||||
new Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0, bottom: 4.0),
|
||||
child: new Text('Ingredients', style: headingStyle)
|
||||
@@ -471,7 +471,7 @@ class RecipeSheet extends StatelessWidget {
|
||||
))..add(
|
||||
new TableRow(
|
||||
children: <Widget>[
|
||||
new SizedBox(),
|
||||
const SizedBox(),
|
||||
new Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0, bottom: 4.0),
|
||||
child: new Text('Steps', style: headingStyle)
|
||||
|
||||
@@ -75,7 +75,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
|
||||
Widget buildCheckbox() {
|
||||
return new Align(
|
||||
alignment: new FractionalOffset(0.5, 0.4),
|
||||
alignment: const FractionalOffset(0.5, 0.4),
|
||||
child: new Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
@@ -109,7 +109,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
|
||||
Widget buildRadio() {
|
||||
return new Align(
|
||||
alignment: new FractionalOffset(0.5, 0.4),
|
||||
alignment: const FractionalOffset(0.5, 0.4),
|
||||
child: new Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
@@ -161,7 +161,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
|
||||
|
||||
Widget buildSwitch() {
|
||||
return new Align(
|
||||
alignment: new FractionalOffset(0.5, 0.4),
|
||||
alignment: const FractionalOffset(0.5, 0.4),
|
||||
child: new Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
|
||||
@@ -135,7 +135,7 @@ class VendorItem extends StatelessWidget {
|
||||
child: new Image.asset(vendor.avatarAsset, fit: ImageFit.cover),
|
||||
),
|
||||
),
|
||||
new SizedBox(width: 8.0),
|
||||
const SizedBox(width: 8.0),
|
||||
new Expanded(
|
||||
child: new Text(vendor.name, style: ShrineTheme.of(context).vendorItemStyle),
|
||||
),
|
||||
|
||||
@@ -43,7 +43,7 @@ class OrderItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
new SizedBox(height: 24.0),
|
||||
const SizedBox(height: 24.0),
|
||||
new Row(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
@@ -66,9 +66,9 @@ class OrderItem extends StatelessWidget {
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
new SizedBox(height: 24.0),
|
||||
const SizedBox(height: 24.0),
|
||||
new Text(product.description, style: theme.featureStyle),
|
||||
new SizedBox(height: 16.0),
|
||||
const SizedBox(height: 16.0),
|
||||
new Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0, right: 88.0),
|
||||
child: new DropdownButtonHideUnderline(
|
||||
@@ -94,7 +94,7 @@ class OrderItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
new SizedBox(height: 16.0),
|
||||
const SizedBox(height: 16.0),
|
||||
new SizedBox(
|
||||
height: 24.0,
|
||||
child: new Align(
|
||||
@@ -102,9 +102,9 @@ class OrderItem extends StatelessWidget {
|
||||
child: new Text(product.vendor.name, style: theme.vendorTitleStyle),
|
||||
),
|
||||
),
|
||||
new SizedBox(height: 16.0),
|
||||
const SizedBox(height: 16.0),
|
||||
new Text(product.vendor.description, style: theme.vendorStyle),
|
||||
new SizedBox(height: 24.0),
|
||||
const SizedBox(height: 24.0),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -186,13 +186,13 @@ class _OrderPageState extends State<OrderPage> {
|
||||
quantity: currentOrder.quantity,
|
||||
quantityChanged: (int value) { updateOrder(quantity: value); },
|
||||
),
|
||||
new SizedBox(height: 24.0),
|
||||
const SizedBox(height: 24.0),
|
||||
]),
|
||||
),
|
||||
new SliverPadding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new SliverGrid(
|
||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 8.0,
|
||||
crossAxisSpacing: 8.0,
|
||||
|
||||
@@ -14,7 +14,7 @@ Widget buildShrine(BuildContext context, Widget child) {
|
||||
return new Theme(
|
||||
data: new ThemeData(
|
||||
primarySwatch: Colors.grey,
|
||||
iconTheme: new IconThemeData(color: const Color(0xFF707070)),
|
||||
iconTheme: const IconThemeData(color: const Color(0xFF707070)),
|
||||
platform: Theme.of(context).platform,
|
||||
),
|
||||
child: new ShrineTheme(child: child)
|
||||
|
||||
@@ -145,7 +145,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
|
||||
onSaved: (InputValue val) { person.password = val.text; }
|
||||
)
|
||||
),
|
||||
new SizedBox(width: 16.0),
|
||||
const SizedBox(width: 16.0),
|
||||
new Expanded(
|
||||
child: new TextField(
|
||||
hintText: 'How do you log in?',
|
||||
|
||||
@@ -134,10 +134,10 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
} else {
|
||||
body = new SingleChildScrollView(
|
||||
child: new Padding(
|
||||
padding: new EdgeInsets.all(16.0),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: new RichText(
|
||||
text: new TextSpan(
|
||||
style: new TextStyle(fontFamily: 'monospace', fontSize: 10.0),
|
||||
style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0),
|
||||
children: <TextSpan>[
|
||||
new DartSyntaxHighlighter(style).format(_exampleCode)
|
||||
]
|
||||
|
||||
@@ -215,9 +215,9 @@ class GalleryDrawer extends StatelessWidget {
|
||||
);
|
||||
|
||||
final Widget aboutItem = new AboutDrawerItem(
|
||||
icon: new FlutterLogo(),
|
||||
icon: const FlutterLogo(),
|
||||
applicationVersion: '2016 Q3 Preview',
|
||||
applicationIcon: new FlutterLogo(),
|
||||
applicationIcon: const FlutterLogo(),
|
||||
applicationLegalese: '© 2016 The Chromium Authors',
|
||||
aboutBoxChildren: <Widget>[
|
||||
new Padding(
|
||||
|
||||
@@ -19,27 +19,27 @@ class SyntaxHighlighterStyle {
|
||||
|
||||
static SyntaxHighlighterStyle lightThemeStyle() {
|
||||
return new SyntaxHighlighterStyle(
|
||||
baseStyle: new TextStyle(color: const Color(0xFF000000)),
|
||||
numberStyle: new TextStyle(color: const Color(0xFF1565C0)),
|
||||
commentStyle: new TextStyle(color: const Color(0xFF9E9E9E)),
|
||||
keywordStyle: new TextStyle(color: const Color(0xFF9C27B0)),
|
||||
stringStyle: new TextStyle(color: const Color(0xFF43A047)),
|
||||
punctuationStyle: new TextStyle(color: const Color(0xFF000000)),
|
||||
classStyle: new TextStyle(color: const Color(0xFF512DA8)),
|
||||
constantStyle: new TextStyle(color: const Color(0xFF795548))
|
||||
baseStyle: const TextStyle(color: const Color(0xFF000000)),
|
||||
numberStyle: const TextStyle(color: const Color(0xFF1565C0)),
|
||||
commentStyle: const TextStyle(color: const Color(0xFF9E9E9E)),
|
||||
keywordStyle: const TextStyle(color: const Color(0xFF9C27B0)),
|
||||
stringStyle: const TextStyle(color: const Color(0xFF43A047)),
|
||||
punctuationStyle: const TextStyle(color: const Color(0xFF000000)),
|
||||
classStyle: const TextStyle(color: const Color(0xFF512DA8)),
|
||||
constantStyle: const TextStyle(color: const Color(0xFF795548))
|
||||
);
|
||||
}
|
||||
|
||||
static SyntaxHighlighterStyle darkThemeStyle() {
|
||||
return new SyntaxHighlighterStyle(
|
||||
baseStyle: new TextStyle(color: const Color(0xFFFFFFFF)),
|
||||
numberStyle: new TextStyle(color: const Color(0xFF1565C0)),
|
||||
commentStyle: new TextStyle(color: const Color(0xFF9E9E9E)),
|
||||
keywordStyle: new TextStyle(color: const Color(0xFF80CBC4)),
|
||||
stringStyle: new TextStyle(color: const Color(0xFF009688)),
|
||||
punctuationStyle: new TextStyle(color: const Color(0xFFFFFFFF)),
|
||||
classStyle: new TextStyle(color: const Color(0xFF009688)),
|
||||
constantStyle: new TextStyle(color: const Color(0xFF795548))
|
||||
baseStyle: const TextStyle(color: const Color(0xFFFFFFFF)),
|
||||
numberStyle: const TextStyle(color: const Color(0xFF1565C0)),
|
||||
commentStyle: const TextStyle(color: const Color(0xFF9E9E9E)),
|
||||
keywordStyle: const TextStyle(color: const Color(0xFF80CBC4)),
|
||||
stringStyle: const TextStyle(color: const Color(0xFF009688)),
|
||||
punctuationStyle: const TextStyle(color: const Color(0xFFFFFFFF)),
|
||||
classStyle: const TextStyle(color: const Color(0xFF009688)),
|
||||
constantStyle: const TextStyle(color: const Color(0xFF795548))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class UpdaterState extends State<Updater> {
|
||||
Future<Null> _checkForUpdates() async {
|
||||
// Only prompt once a day
|
||||
if (_lastUpdateCheck != null &&
|
||||
new DateTime.now().difference(_lastUpdateCheck) < new Duration(days: 1)) {
|
||||
new DateTime.now().difference(_lastUpdateCheck) < const Duration(days: 1)) {
|
||||
return; // We already checked for updates recently
|
||||
}
|
||||
_lastUpdateCheck = new DateTime.now();
|
||||
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
final Point allDemosOrigin = tester.getTopRight(find.text('Demos'));
|
||||
final Finder button = find.text('Buttons');
|
||||
while (button.evaluate().isEmpty) {
|
||||
await tester.scrollAt(allDemosOrigin, new Offset(0.0, -100.0));
|
||||
await tester.scrollAt(allDemosOrigin, const Offset(0.0, -100.0));
|
||||
await tester.pump(); // start the scroll
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@ void main() {
|
||||
await new Future<Null>.delayed(kWaitBetweenActions);
|
||||
}
|
||||
await completer.future;
|
||||
}, timeout: new Timeout(new Duration(minutes: 1)));
|
||||
}, timeout: const Timeout(const Duration(minutes: 1)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,14 +34,14 @@ void main() {
|
||||
// https://github.com/flutter/flutter/issues/3316
|
||||
// Scroll down
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(stockList, 0.0, -300.0, new Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
await driver.scroll(stockList, 0.0, -300.0, const Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
|
||||
// Scroll up
|
||||
for (int i = 0; i < 5; i++) {
|
||||
await driver.scroll(stockList, 0.0, 300.0, new Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 500));
|
||||
await driver.scroll(stockList, 0.0, 300.0, const Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ final List<String> unsynchedDemoTitles = <String>[
|
||||
'Progress indicators',
|
||||
];
|
||||
|
||||
final FileSystem _fs = new LocalFileSystem();
|
||||
final FileSystem _fs = const LocalFileSystem();
|
||||
|
||||
const Duration kWaitBetweenActions = const Duration(milliseconds: 250);
|
||||
|
||||
@@ -123,7 +123,7 @@ Future<Null> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
|
||||
|
||||
// Save the durations Map to a file.
|
||||
final File file = await _fs.file(outputPath).create(recursive: true);
|
||||
await file.writeAsString(new JsonEncoder.withIndent(' ').convert(durations));
|
||||
await file.writeAsString(const JsonEncoder.withIndent(' ').convert(durations));
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -176,6 +176,6 @@ void main() {
|
||||
await summary.writeSummaryToFile('transitions', pretty: true);
|
||||
String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json');
|
||||
await saveDurationsHistogram(timeline.json['traceEvents'], histogramPath);
|
||||
}, timeout: new Timeout(new Duration(minutes: 5)));
|
||||
}, timeout: const Timeout(const Duration(minutes: 5)));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user