prefer const constructors (#8316)
This commit is contained in:
committed by
Adam Barth
parent
663862557b
commit
e9a775bf38
@@ -73,7 +73,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: new ListView.builder(
|
||||
key: new Key('main-scroll'), // this key is used by the driver test
|
||||
key: const Key('main-scroll'), // this key is used by the driver test
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index % 2 == 0)
|
||||
return new FancyImageItem(index, key: new ValueKey<int>(index));
|
||||
@@ -154,7 +154,7 @@ class MenuItemWithIcon extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
new Icon(icon),
|
||||
new Padding(
|
||||
padding: new EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: new Text(title)
|
||||
),
|
||||
new Text(subtitle, style: Theme.of(context).textTheme.caption)
|
||||
@@ -177,7 +177,7 @@ class FancyImageItem extends StatelessWidget {
|
||||
new ItemImageBox(),
|
||||
new InfoBar(),
|
||||
new Padding(
|
||||
padding: new EdgeInsets.symmetric(horizontal: 8.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: new Divider()
|
||||
),
|
||||
new IconBar(),
|
||||
@@ -199,7 +199,7 @@ class FancyGalleryItem extends StatelessWidget {
|
||||
new ItemGalleryBox(index),
|
||||
new InfoBar(),
|
||||
new Padding(
|
||||
padding: new EdgeInsets.symmetric(horizontal: 8.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: new Divider()
|
||||
),
|
||||
new IconBar(),
|
||||
@@ -213,7 +213,7 @@ class InfoBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
@@ -229,7 +229,7 @@ class IconBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.only(left: 16.0, right: 16.0),
|
||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
@@ -275,7 +275,7 @@ class MiniIconWithText extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
padding: new EdgeInsets.only(right: 8.0),
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: new Container(
|
||||
width: 16.0,
|
||||
height: 16.0,
|
||||
@@ -312,12 +312,12 @@ class UserHeader extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
padding: new EdgeInsets.only(right: 8.0),
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: new Image(
|
||||
image: new AssetImage('packages/flutter_gallery_assets/ali_connors_sml.png'),
|
||||
width: 32.0,
|
||||
@@ -332,9 +332,9 @@ class UserHeader extends StatelessWidget {
|
||||
new RichText(text: new TextSpan(
|
||||
style: Theme.of(context).textTheme.body1,
|
||||
children: <TextSpan>[
|
||||
new TextSpan(text: userName, style: new TextStyle(fontWeight: FontWeight.bold)),
|
||||
new TextSpan(text: ' shared a new '),
|
||||
new TextSpan(text: 'photo', style: new TextStyle(fontWeight: FontWeight.bold))
|
||||
new TextSpan(text: userName, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
const TextSpan(text: ' shared a new '),
|
||||
const TextSpan(text: 'photo', style: const TextStyle(fontWeight: FontWeight.bold))
|
||||
]
|
||||
)),
|
||||
new Row(
|
||||
@@ -357,7 +357,7 @@ class ItemDescription extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
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.')
|
||||
);
|
||||
}
|
||||
@@ -367,7 +367,7 @@ class ItemImageBox extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Card(
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -404,16 +404,16 @@ class ItemImageBox extends StatelessWidget {
|
||||
backgroundColor: Colors.black54,
|
||||
borderRadius: new BorderRadius.circular(2.0)
|
||||
),
|
||||
padding: new EdgeInsets.all(4.0),
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: new RichText(
|
||||
text: new TextSpan(
|
||||
style: new TextStyle(color: Colors.white),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
children: <TextSpan>[
|
||||
new TextSpan(
|
||||
const TextSpan(
|
||||
text: 'Photo by '
|
||||
),
|
||||
new TextSpan(
|
||||
style: new TextStyle(fontWeight: FontWeight.bold),
|
||||
const TextSpan(
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
text: 'Magic Mike'
|
||||
)
|
||||
]
|
||||
@@ -425,7 +425,7 @@ class ItemImageBox extends StatelessWidget {
|
||||
)
|
||||
,
|
||||
new Padding(
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
@@ -465,7 +465,7 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
return new Container(
|
||||
key: new Key(tabName),
|
||||
child: new Padding(
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Card(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
@@ -491,7 +491,7 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
),
|
||||
new Expanded(
|
||||
child: new Padding(
|
||||
padding: new EdgeInsets.only(left: 8.0),
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Text('This is item $tabName'),
|
||||
)
|
||||
)
|
||||
@@ -550,7 +550,7 @@ class BottomBarButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
|
||||
@@ -27,14 +27,14 @@ void main() {
|
||||
|
||||
// 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));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Future<Null> main() async {
|
||||
stocks.main();
|
||||
await tester.pump(); // Start startup animation
|
||||
await tester.pump(const Duration(seconds: 1)); // Complete startup animation
|
||||
await tester.tapAt(new Point(20.0, 40.0)); // Open drawer
|
||||
await tester.tapAt(const Point(20.0, 40.0)); // Open drawer
|
||||
await tester.pump(); // Start drawer animation
|
||||
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ Future<Null> main() async {
|
||||
stocks.main();
|
||||
await tester.pump(); // Start startup animation
|
||||
await tester.pump(const Duration(seconds: 1)); // Complete startup animation
|
||||
await tester.tapAt(new Point(20.0, 40.0)); // Open drawer
|
||||
await tester.tapAt(const Point(20.0, 40.0)); // Open drawer
|
||||
await tester.pump(); // Start drawer animation
|
||||
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ Future<Null> main(List<String> rawArgs) async {
|
||||
exitCode = 1;
|
||||
|
||||
print('Task result:');
|
||||
print(new JsonEncoder.withIndent(' ').convert(result));
|
||||
print(const JsonEncoder.withIndent(' ').convert(result));
|
||||
section('Finished task "$taskName"');
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ final ArgParser _argParser = new ArgParser()
|
||||
splitCommas: true,
|
||||
callback: (List<String> value) {
|
||||
if (value.isNotEmpty) {
|
||||
throw new FormatException(
|
||||
throw const FormatException(
|
||||
'Invalid option --test. Did you mean --task (-t)?',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
|
||||
});
|
||||
|
||||
StreamSubscription<String> stdoutSub = runner.stdout
|
||||
.transform(new Utf8Decoder())
|
||||
.transform(new LineSplitter())
|
||||
.transform(const Utf8Decoder())
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) {
|
||||
if (!silent) {
|
||||
stdout.writeln('[$taskName] [STDOUT] $line');
|
||||
@@ -51,8 +51,8 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
|
||||
});
|
||||
|
||||
StreamSubscription<String> stderrSub = runner.stderr
|
||||
.transform(new Utf8Decoder())
|
||||
.transform(new LineSplitter())
|
||||
.transform(const Utf8Decoder())
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) {
|
||||
stderr.writeln('[$taskName] [STDERR] $line');
|
||||
});
|
||||
|
||||
@@ -318,7 +318,7 @@ T requireConfigProperty<T>(Map<String, dynamic> map, String propertyName) {
|
||||
}
|
||||
|
||||
String jsonEncode(dynamic data) {
|
||||
return new JsonEncoder.withIndent(' ').convert(data) + '\n';
|
||||
return const JsonEncoder.withIndent(' ').convert(data) + '\n';
|
||||
}
|
||||
|
||||
Future<Null> getFlutter(String revision) async {
|
||||
|
||||
@@ -305,12 +305,12 @@ class AndroidBackButtonMemoryTest {
|
||||
// Perform a series of back button suspend and resume cycles.
|
||||
for (int i = 0; i < 10; i++) {
|
||||
await device.shellExec('input', <String>['keyevent', 'KEYCODE_BACK']);
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 1000));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 1000));
|
||||
String output = await device.shellEval('am', <String>['start', '-n', 'io.flutter.examples.gallery/io.flutter.app.FlutterActivity']);
|
||||
print(output);
|
||||
if (output.contains('Error'))
|
||||
return new TaskResult.failure('unable to launch activity');
|
||||
await new Future<Null>.delayed(new Duration(milliseconds: 1000));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 1000));
|
||||
}
|
||||
|
||||
Map<String, dynamic> endData = await device.getMemoryStats(packageName);
|
||||
|
||||
@@ -27,7 +27,7 @@ class ExampleDragTargetState extends State<ExampleDragTarget> {
|
||||
builder: (BuildContext context, List<Color> data, List<dynamic> rejectedData) {
|
||||
return new Container(
|
||||
height: 100.0,
|
||||
margin: new EdgeInsets.all(10.0),
|
||||
margin: const EdgeInsets.all(10.0),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border.all(
|
||||
width: 3.0,
|
||||
|
||||
@@ -169,7 +169,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||
setState(() {
|
||||
markers[MarkerType.touch] = globalPosition;
|
||||
final RenderBox box = target.currentContext.findRenderObject();
|
||||
markers[MarkerType.topLeft] = box.localToGlobal(new Point(0.0, 0.0));
|
||||
markers[MarkerType.topLeft] = box.localToGlobal(const Point(0.0, 0.0));
|
||||
final Size size = box.size;
|
||||
markers[MarkerType.bottomRight] = box.localToGlobal(new Point(size.width, size.height));
|
||||
final ScrollableState scrollable = Scrollable.of(target.currentContext);
|
||||
|
||||
@@ -40,7 +40,7 @@ class PageViewAppState extends State<PageViewApp> {
|
||||
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
|
||||
|
||||
List<CardModel> cardModels;
|
||||
Size pageSize = new Size(200.0, 200.0);
|
||||
Size pageSize = const Size(200.0, 200.0);
|
||||
Axis scrollDirection = Axis.horizontal;
|
||||
bool itemsWrap = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user