Commit 00cbdb38 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by Adam Barth

prefer const constructor (#8031)

parent e151a1a4
...@@ -232,7 +232,7 @@ class SnackBar extends StatelessWidget { ...@@ -232,7 +232,7 @@ class SnackBar extends StatelessWidget {
child: new Semantics( child: new Semantics(
container: true, container: true,
child: new Dismissable( child: new Dismissable(
key: new Key('dismissable'), key: const Key('dismissable'),
direction: DismissDirection.down, direction: DismissDirection.down,
resizeDuration: null, resizeDuration: null,
onDismissed: (DismissDirection direction) { onDismissed: (DismissDirection direction) {
......
...@@ -135,7 +135,7 @@ typedef void GlobalKeyRemoveListener(GlobalKey key); ...@@ -135,7 +135,7 @@ typedef void GlobalKeyRemoveListener(GlobalKey key);
/// A key that is unique across the entire app. /// A key that is unique across the entire app.
/// ///
/// Global keys uniquely indentify elements. Global keys provide access to other /// Global keys uniquely identify elements. Global keys provide access to other
/// objects that are associated with elements, such as the a [BuildContext] and, /// objects that are associated with elements, such as the a [BuildContext] and,
/// for [StatefulWidget]s, a [State]. /// for [StatefulWidget]s, a [State].
/// ///
......
...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('Drawer control test', (WidgetTester tester) async { testWidgets('Drawer control test', (WidgetTester tester) async {
final Key containerKey = new Key('container'); final Key containerKey = const Key('container');
await tester.pumpWidget( await tester.pumpWidget(
new Scaffold( new Scaffold(
......
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
testWidgets('Floating action animation', (WidgetTester tester) async { testWidgets('Floating action animation', (WidgetTester tester) async {
await tester.pumpWidget(new Scaffold( await tester.pumpWidget(new Scaffold(
floatingActionButton: new FloatingActionButton( floatingActionButton: new FloatingActionButton(
key: new Key("one"), key: const Key('one'),
onPressed: null, onPressed: null,
child: new Text("1") child: new Text("1")
) )
...@@ -54,7 +54,7 @@ void main() { ...@@ -54,7 +54,7 @@ void main() {
await tester.pumpWidget(new Scaffold( await tester.pumpWidget(new Scaffold(
floatingActionButton: new FloatingActionButton( floatingActionButton: new FloatingActionButton(
key: new Key("two"), key: const Key('two'),
onPressed: null, onPressed: null,
child: new Text("2") child: new Text("2")
) )
...@@ -68,7 +68,7 @@ void main() { ...@@ -68,7 +68,7 @@ void main() {
await tester.pumpWidget(new Scaffold( await tester.pumpWidget(new Scaffold(
floatingActionButton: new FloatingActionButton( floatingActionButton: new FloatingActionButton(
key: new Key("one"), key: const Key('one'),
onPressed: null, onPressed: null,
child: new Text("1") child: new Text("1")
) )
......
...@@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; ...@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
void main() { void main() {
testWidgets('SnackBar control test', (WidgetTester tester) async { testWidgets('SnackBar control test', (WidgetTester tester) async {
String helloSnackBar = 'Hello SnackBar'; String helloSnackBar = 'Hello SnackBar';
Key tapTarget = new Key('tap-target'); Key tapTarget = const Key('tap-target');
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
home: new Scaffold( home: new Scaffold(
body: new Builder( body: new Builder(
...@@ -53,7 +53,7 @@ void main() { ...@@ -53,7 +53,7 @@ void main() {
testWidgets('SnackBar twice test', (WidgetTester tester) async { testWidgets('SnackBar twice test', (WidgetTester tester) async {
int snackBarCount = 0; int snackBarCount = 0;
Key tapTarget = new Key('tap-target'); Key tapTarget = const Key('tap-target');
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
home: new Scaffold( home: new Scaffold(
body: new Builder( body: new Builder(
...@@ -128,7 +128,7 @@ void main() { ...@@ -128,7 +128,7 @@ void main() {
testWidgets('SnackBar cancel test', (WidgetTester tester) async { testWidgets('SnackBar cancel test', (WidgetTester tester) async {
int snackBarCount = 0; int snackBarCount = 0;
Key tapTarget = new Key('tap-target'); Key tapTarget = const Key('tap-target');
int time; int time;
ScaffoldFeatureController<SnackBar, SnackBarClosedReason> lastController; ScaffoldFeatureController<SnackBar, SnackBarClosedReason> lastController;
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
...@@ -214,7 +214,7 @@ void main() { ...@@ -214,7 +214,7 @@ void main() {
testWidgets('SnackBar dismiss test', (WidgetTester tester) async { testWidgets('SnackBar dismiss test', (WidgetTester tester) async {
int snackBarCount = 0; int snackBarCount = 0;
Key tapTarget = new Key('tap-target'); Key tapTarget = const Key('tap-target');
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
home: new Scaffold( home: new Scaffold(
body: new Builder( body: new Builder(
......
...@@ -168,7 +168,7 @@ void main() { ...@@ -168,7 +168,7 @@ void main() {
testWidgets('Scrollable TabBar tap centers selected tab', (WidgetTester tester) async { testWidgets('Scrollable TabBar tap centers selected tab', (WidgetTester tester) async {
List<String> tabs = <String>['AAAAAA', 'BBBBBB', 'CCCCCC', 'DDDDDD', 'EEEEEE', 'FFFFFF', 'GGGGGG', 'HHHHHH', 'IIIIII', 'JJJJJJ', 'KKKKKK', 'LLLLLL']; List<String> tabs = <String>['AAAAAA', 'BBBBBB', 'CCCCCC', 'DDDDDD', 'EEEEEE', 'FFFFFF', 'GGGGGG', 'HHHHHH', 'IIIIII', 'JJJJJJ', 'KKKKKK', 'LLLLLL'];
Key tabBarKey = new Key('TabBar'); Key tabBarKey = const Key('TabBar');
await tester.pumpWidget(buildFrame(tabs: tabs, value: 'AAAAAA', isScrollable: true, tabBarKey: tabBarKey)); await tester.pumpWidget(buildFrame(tabs: tabs, value: 'AAAAAA', isScrollable: true, tabBarKey: tabBarKey));
TabController controller = DefaultTabController.of(tester.element(find.text('AAAAAA'))); TabController controller = DefaultTabController.of(tester.element(find.text('AAAAAA')));
expect(controller, isNotNull); expect(controller, isNotNull);
...@@ -189,7 +189,7 @@ void main() { ...@@ -189,7 +189,7 @@ void main() {
testWidgets('TabBar can be scrolled independent of the selection', (WidgetTester tester) async { testWidgets('TabBar can be scrolled independent of the selection', (WidgetTester tester) async {
List<String> tabs = <String>['AAAA', 'BBBB', 'CCCC', 'DDDD', 'EEEE', 'FFFF', 'GGGG', 'HHHH', 'IIII', 'JJJJ', 'KKKK', 'LLLL']; List<String> tabs = <String>['AAAA', 'BBBB', 'CCCC', 'DDDD', 'EEEE', 'FFFF', 'GGGG', 'HHHH', 'IIII', 'JJJJ', 'KKKK', 'LLLL'];
Key tabBarKey = new Key('TabBar'); Key tabBarKey = const Key('TabBar');
await tester.pumpWidget(buildFrame(tabs: tabs, value: 'AAAA', isScrollable: true, tabBarKey: tabBarKey)); await tester.pumpWidget(buildFrame(tabs: tabs, value: 'AAAA', isScrollable: true, tabBarKey: tabBarKey));
TabController controller = DefaultTabController.of(tester.element(find.text('AAAA'))); TabController controller = DefaultTabController.of(tester.element(find.text('AAAA')));
expect(controller, isNotNull); expect(controller, isNotNull);
......
...@@ -38,7 +38,7 @@ Future<Point> startPicker(WidgetTester tester, ValueChanged<TimeOfDay> onChanged ...@@ -38,7 +38,7 @@ Future<Point> startPicker(WidgetTester tester, ValueChanged<TimeOfDay> onChanged
await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged)); await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged));
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1)); await tester.pumpUntilNoTransientCallbacks(const Duration(seconds: 1));
return tester.getCenter(find.byKey(new Key('time-picker-dial'))); return tester.getCenter(find.byKey(const Key('time-picker-dial')));
} }
Future<Null> finishPicker(WidgetTester tester) async { Future<Null> finishPicker(WidgetTester tester) async {
......
...@@ -8,9 +8,9 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -8,9 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('UserAccountsDrawerHeader test', (WidgetTester tester) async { testWidgets('UserAccountsDrawerHeader test', (WidgetTester tester) async {
final Key avatarA = new Key('A'); final Key avatarA = const Key('A');
final Key avatarC = new Key('C'); final Key avatarC = const Key('C');
final Key avatarD = new Key('D'); final Key avatarD = const Key('D');
await tester.pumpWidget( await tester.pumpWidget(
new Material( new Material(
...@@ -146,7 +146,7 @@ void main() { ...@@ -146,7 +146,7 @@ void main() {
)); ));
expect(find.text('A'), findsOneWidget); expect(find.text('A'), findsOneWidget);
final Key avatarA = new Key('A'); final Key avatarA = const Key('A');
await tester.pumpWidget(buildFrame( await tester.pumpWidget(buildFrame(
currentAccountPicture: new CircleAvatar(key: avatarA, child: new Text('A')), currentAccountPicture: new CircleAvatar(key: avatarA, child: new Text('A')),
accountName: new Text('accountName'), accountName: new Text('accountName'),
......
...@@ -10,7 +10,7 @@ void main() { ...@@ -10,7 +10,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Center(
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: new TextStyle( style: const TextStyle(
fontFamily: 'Ahem', fontFamily: 'Ahem',
fontSize: 100.0, fontSize: 100.0,
), ),
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
baseline: 180.0, baseline: 180.0,
baselineType: TextBaseline.alphabetic, baselineType: TextBaseline.alphabetic,
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: new TextStyle( style: const TextStyle(
fontFamily: 'Ahem', fontFamily: 'Ahem',
fontSize: 100.0, fontSize: 100.0,
), ),
......
...@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
final Key blockKey = new Key('test'); final Key blockKey = const Key('test');
void main() { void main() {
testWidgets('Cannot scroll a non-overflowing block', (WidgetTester tester) async { testWidgets('Cannot scroll a non-overflowing block', (WidgetTester tester) async {
......
...@@ -23,7 +23,7 @@ void main() { ...@@ -23,7 +23,7 @@ void main() {
}); });
testWidgets('Bordered Container insets its child', (WidgetTester tester) async { testWidgets('Bordered Container insets its child', (WidgetTester tester) async {
Key key = new Key('outerContainer'); Key key = const Key('outerContainer');
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Center(
child: new Container( child: new Container(
...@@ -42,7 +42,7 @@ void main() { ...@@ -42,7 +42,7 @@ void main() {
testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async { testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/7672 // Regression test for https://github.com/flutter/flutter/issues/7672
final Key key = new Key('Container with BoxDecoration'); final Key key = const Key('Container with BoxDecoration');
Widget buildFrame(Border border) { Widget buildFrame(Border border) {
return new Center( return new Center(
child: new Container( child: new Container(
......
...@@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart'; ...@@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart';
void main() { void main() {
testWidgets('Column with one flexible child', (WidgetTester tester) async { testWidgets('Column with one flexible child', (WidgetTester tester) async {
final Key columnKey = new Key('column'); final Key columnKey = const Key('column');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
// Default is MainAxisAlignment.start so children so the children's // Default is MainAxisAlignment.start so children so the children's
...@@ -54,10 +54,10 @@ void main() { ...@@ -54,10 +54,10 @@ void main() {
}); });
testWidgets('Column with default main axis parameters', (WidgetTester tester) async { testWidgets('Column with default main axis parameters', (WidgetTester tester) async {
final Key columnKey = new Key('column'); final Key columnKey = const Key('column');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
// Default is MainAxisAlignment.start so children so the children's // Default is MainAxisAlignment.start so children so the children's
...@@ -100,9 +100,9 @@ void main() { ...@@ -100,9 +100,9 @@ void main() {
}); });
testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async { testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async {
final Key columnKey = new Key('column'); final Key columnKey = const Key('column');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
// The 100x100 children's top edges should be at 200, 300 // The 100x100 children's top edges should be at 200, 300
...@@ -138,10 +138,10 @@ void main() { ...@@ -138,10 +138,10 @@ void main() {
}); });
testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async { testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async {
final Key columnKey = new Key('column'); final Key columnKey = const Key('column');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
// The 100x100 children's top edges should be at 300, 400, 500. // The 100x100 children's top edges should be at 300, 400, 500.
...@@ -184,10 +184,10 @@ void main() { ...@@ -184,10 +184,10 @@ void main() {
}); });
testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
final Key columnKey = new Key('column'); final Key columnKey = const Key('column');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
// The 100x100 children's top edges should be at 0, 250, 500 // The 100x100 children's top edges should be at 0, 250, 500
...@@ -230,11 +230,11 @@ void main() { ...@@ -230,11 +230,11 @@ void main() {
}); });
testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async { testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
final Key columnKey = new Key('column'); final Key columnKey = const Key('column');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
final Key child3Key = new Key('child3'); final Key child3Key = const Key('child3');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
// The 100x100 children's top edges should be at 25, 175, 325, 475 // The 100x100 children's top edges should be at 25, 175, 325, 475
...@@ -284,10 +284,10 @@ void main() { ...@@ -284,10 +284,10 @@ void main() {
}); });
testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
final Key columnKey = new Key('column'); final Key columnKey = const Key('column');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
// The 100x20 children's top edges should be at 135, 290, 445 // The 100x20 children's top edges should be at 135, 290, 445
...@@ -330,7 +330,7 @@ void main() { ...@@ -330,7 +330,7 @@ void main() {
}); });
testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async { testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async {
final Key flexKey = new Key('flexKey'); final Key flexKey = const Key('flexKey');
// Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisSize.max so the Column should be as high as the test: 600.
await tester.pumpWidget(new Center( await tester.pumpWidget(new Center(
...@@ -363,7 +363,7 @@ void main() { ...@@ -363,7 +363,7 @@ void main() {
}); });
testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async { testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
final Key childKey = new Key('childKey'); final Key childKey = const Key('childKey');
await tester.pumpWidget(new Center( await tester.pumpWidget(new Center(
child: new Container( child: new Container(
......
...@@ -21,13 +21,13 @@ Widget buildSingleChildScrollView(Axis scrollDirection, { bool reverse: false }) ...@@ -21,13 +21,13 @@ Widget buildSingleChildScrollView(Axis scrollDirection, { bool reverse: false })
child: new BlockBody( child: new BlockBody(
mainAxis: scrollDirection, mainAxis: scrollDirection,
children: <Widget>[ children: <Widget>[
new Container(key: new ValueKey<int>(0), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(0), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(1), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(1), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(2), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(2), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(3), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(3), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(4), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(4), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(5), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(5), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(6), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(6), width: 200.0, height: 200.0),
], ],
), ),
), ),
...@@ -45,13 +45,13 @@ Widget buildListView(Axis scrollDirection, { bool reverse: false, bool shrinkWra ...@@ -45,13 +45,13 @@ Widget buildListView(Axis scrollDirection, { bool reverse: false, bool shrinkWra
reverse: reverse, reverse: reverse,
shrinkWrap: shrinkWrap, shrinkWrap: shrinkWrap,
children: <Widget>[ children: <Widget>[
new Container(key: new ValueKey<int>(0), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(0), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(1), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(1), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(2), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(2), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(3), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(3), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(4), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(4), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(5), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(5), width: 200.0, height: 200.0),
new Container(key: new ValueKey<int>(6), width: 200.0, height: 200.0), new Container(key: const ValueKey<int>(6), width: 200.0, height: 200.0),
], ],
), ),
), ),
...@@ -189,7 +189,7 @@ void main() { ...@@ -189,7 +189,7 @@ void main() {
child: new Transform( child: new Transform(
transform: new Matrix4.rotationZ(math.PI), transform: new Matrix4.rotationZ(math.PI),
child: new Container( child: new Container(
key: new ValueKey<int>(0), key: const ValueKey<int>(0),
width: 100.0, width: 100.0,
height: 100.0, height: 100.0,
decoration: const BoxDecoration( decoration: const BoxDecoration(
...@@ -391,7 +391,7 @@ void main() { ...@@ -391,7 +391,7 @@ void main() {
viewportBuilder: (BuildContext context, ViewportOffset offset) { viewportBuilder: (BuildContext context, ViewportOffset offset) {
return new Viewport2( return new Viewport2(
offset: offset, offset: offset,
center: new ValueKey<int>(4), center: const ValueKey<int>(4),
slivers: <Widget>[ slivers: <Widget>[
buildSliver(0), buildSliver(0),
buildSliver(1), buildSliver(1),
...@@ -441,7 +441,7 @@ void main() { ...@@ -441,7 +441,7 @@ void main() {
child: new Transform( child: new Transform(
transform: new Matrix4.rotationZ(math.PI), transform: new Matrix4.rotationZ(math.PI),
child: new Container( child: new Container(
key: new ValueKey<int>(0), key: const ValueKey<int>(0),
width: 100.0, width: 100.0,
height: 100.0, height: 100.0,
decoration: const BoxDecoration( decoration: const BoxDecoration(
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Key firstKey = new Key('first'); Key firstKey = const Key('first');
Key secondKey = new Key('second'); Key secondKey = const Key('second');
Key thirdKey = new Key('third'); Key thirdKey = const Key('third');
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => new Material( '/': (BuildContext context) => new Material(
......
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
didTapRight = true; didTapRight = true;
}; };
Key textKey = new Key('text'); Key textKey = const Key('text');
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Center(
......
...@@ -47,11 +47,11 @@ void main() { ...@@ -47,11 +47,11 @@ void main() {
expect(new ObjectKey(const Object()) == new ObjectKey(const Object()), isTrue); // ignore: prefer_const_constructors expect(new ObjectKey(const Object()) == new ObjectKey(const Object()), isTrue); // ignore: prefer_const_constructors
expect(new ObjectKey(new Object()) == new ObjectKey(new Object()), isFalse); expect(new ObjectKey(new Object()) == new ObjectKey(new Object()), isFalse);
expect(new ValueKey<bool>(true), hasOneLineDescription); expect(const ValueKey<bool>(true), hasOneLineDescription);
expect(new UniqueKey(), hasOneLineDescription); expect(new UniqueKey(), hasOneLineDescription);
expect(new ObjectKey(true), hasOneLineDescription); expect(const ObjectKey(true), hasOneLineDescription);
expect(new GlobalKey(), hasOneLineDescription); expect(new GlobalKey(), hasOneLineDescription);
expect(new GlobalKey(debugLabel: 'hello'), hasOneLineDescription); expect(new GlobalKey(debugLabel: 'hello'), hasOneLineDescription);
expect(new GlobalObjectKey(true), hasOneLineDescription); expect(const GlobalObjectKey(true), hasOneLineDescription);
}); });
} }
...@@ -61,7 +61,7 @@ void main() { ...@@ -61,7 +61,7 @@ void main() {
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new DecoratedBox(decoration: kBoxDecorationA), new DecoratedBox(decoration: kBoxDecorationA),
new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB), new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB),
new DecoratedBox(decoration: kBoxDecorationC), new DecoratedBox(decoration: kBoxDecorationC),
] ]
) )
...@@ -72,9 +72,9 @@ void main() { ...@@ -72,9 +72,9 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB), new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB),
new DecoratedBox(decoration: kBoxDecorationC), new DecoratedBox(decoration: kBoxDecorationC),
new DecoratedBox(key: new Key('a'), decoration: kBoxDecorationA), new DecoratedBox(key: const Key('a'), decoration: kBoxDecorationA),
] ]
) )
); );
...@@ -84,9 +84,9 @@ void main() { ...@@ -84,9 +84,9 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new DecoratedBox(key: new Key('a'), decoration: kBoxDecorationA), new DecoratedBox(key: const Key('a'), decoration: kBoxDecorationA),
new DecoratedBox(decoration: kBoxDecorationC), new DecoratedBox(decoration: kBoxDecorationC),
new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB), new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB),
] ]
) )
); );
...@@ -193,11 +193,11 @@ void main() { ...@@ -193,11 +193,11 @@ void main() {
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new Container( new Container(
key: new Key('b'), key: const Key('b'),
child: new DecoratedBox(decoration: kBoxDecorationB) child: new DecoratedBox(decoration: kBoxDecorationB)
), ),
new Container( new Container(
key: new Key('a'), key: const Key('a'),
child: new DecoratedBox(decoration: kBoxDecorationA) child: new DecoratedBox(decoration: kBoxDecorationA)
), ),
] ]
...@@ -210,11 +210,11 @@ void main() { ...@@ -210,11 +210,11 @@ void main() {
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new Container( new Container(
key: new Key('a'), key: const Key('a'),
child: new DecoratedBox(decoration: kBoxDecorationA) child: new DecoratedBox(decoration: kBoxDecorationA)
), ),
new Container( new Container(
key: new Key('b'), key: const Key('b'),
child: new DecoratedBox(decoration: kBoxDecorationB) child: new DecoratedBox(decoration: kBoxDecorationB)
), ),
] ]
...@@ -283,7 +283,7 @@ void main() { ...@@ -283,7 +283,7 @@ void main() {
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new FlipWidget( new FlipWidget(
key: new Key('flip'), key: const Key('flip'),
left: new DecoratedBox(decoration: kBoxDecorationA), left: new DecoratedBox(decoration: kBoxDecorationA),
right: new DecoratedBox(decoration: kBoxDecorationB) right: new DecoratedBox(decoration: kBoxDecorationB)
), ),
...@@ -294,9 +294,9 @@ void main() { ...@@ -294,9 +294,9 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new DecoratedBox(key: new Key('c'), decoration: kBoxDecorationC), new DecoratedBox(key: const Key('c'), decoration: kBoxDecorationC),
new FlipWidget( new FlipWidget(
key: new Key('flip'), key: const Key('flip'),
left: new DecoratedBox(decoration: kBoxDecorationA), left: new DecoratedBox(decoration: kBoxDecorationA),
right: new DecoratedBox(decoration: kBoxDecorationB) right: new DecoratedBox(decoration: kBoxDecorationB)
), ),
...@@ -315,11 +315,11 @@ void main() { ...@@ -315,11 +315,11 @@ void main() {
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new FlipWidget( new FlipWidget(
key: new Key('flip'), key: const Key('flip'),
left: new DecoratedBox(decoration: kBoxDecorationA), left: new DecoratedBox(decoration: kBoxDecorationA),
right: new DecoratedBox(decoration: kBoxDecorationB) right: new DecoratedBox(decoration: kBoxDecorationB)
), ),
new DecoratedBox(key: new Key('c'), decoration: kBoxDecorationC), new DecoratedBox(key: const Key('c'), decoration: kBoxDecorationC),
] ]
) )
); );
......
...@@ -162,7 +162,7 @@ void main() { ...@@ -162,7 +162,7 @@ void main() {
}); });
testWidgets('Navigator.of fails gracefully when not found in context', (WidgetTester tester) async { testWidgets('Navigator.of fails gracefully when not found in context', (WidgetTester tester) async {
Key targetKey = new Key('foo'); Key targetKey = const Key('foo');
dynamic exception; dynamic exception;
Widget widget = new ThirdWidget( Widget widget = new ThirdWidget(
targetKey: targetKey, targetKey: targetKey,
......
...@@ -206,7 +206,7 @@ void main() { ...@@ -206,7 +206,7 @@ void main() {
new Container( new Container(
width: 2000.0, width: 2000.0,
height: 2000.0, height: 2000.0,
decoration: new BoxDecoration( decoration: const BoxDecoration(
backgroundColor: const Color(0xFF00FF00), backgroundColor: const Color(0xFF00FF00),
), ),
), ),
......
...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
void main() { void main() {
testWidgets('PageStorage read and write', (WidgetTester tester) async { testWidgets('PageStorage read and write', (WidgetTester tester) async {
final Key builderKey = new Key('builderKey'); final Key builderKey = const Key('builderKey');
StateSetter setState; StateSetter setState;
int storedValue = 0; int storedValue = 0;
...@@ -56,7 +56,7 @@ void main() { ...@@ -56,7 +56,7 @@ void main() {
); );
} }
Key key = new Key('Key one'); Key key = const Key('Key one');
await tester.pumpWidget(buildWidthKey(key)); await tester.pumpWidget(buildWidthKey(key));
Element builderElement = tester.element(find.byKey(key)); Element builderElement = tester.element(find.byKey(key));
expect(PageStorage.of(builderElement), isNotNull); expect(PageStorage.of(builderElement), isNotNull);
...@@ -65,7 +65,7 @@ void main() { ...@@ -65,7 +65,7 @@ void main() {
// New StatefulBuilder widget - different key - but the same PageStorage identifier. // New StatefulBuilder widget - different key - but the same PageStorage identifier.
key = new Key('Key two'); key = const Key('Key two');
await tester.pumpWidget(buildWidthKey(key)); await tester.pumpWidget(buildWidthKey(key));
builderElement = tester.element(find.byKey(key)); builderElement = tester.element(find.byKey(key));
expect(PageStorage.of(builderElement), isNotNull); expect(PageStorage.of(builderElement), isNotNull);
......
...@@ -199,7 +199,7 @@ void main() { ...@@ -199,7 +199,7 @@ void main() {
itemExtent: 100.0, itemExtent: 100.0,
children: <Widget>[ children: <Widget>[
new Container( new Container(
key: new Key('container'), key: const Key('container'),
height: 100.0, height: 100.0,
child: new StateMarker(key: key), child: new StateMarker(key: key),
), ),
......
...@@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart'; ...@@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart';
void main() { void main() {
testWidgets('Row with one Flexible child', (WidgetTester tester) async { testWidgets('Row with one Flexible child', (WidgetTester tester) async {
final Key rowKey = new Key('row'); final Key rowKey = const Key('row');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisSize.max so the Row should be as wide as the test: 800.
// Default is MainAxisAlignment.start so children so the children's // Default is MainAxisAlignment.start so children so the children's
...@@ -54,10 +54,10 @@ void main() { ...@@ -54,10 +54,10 @@ void main() {
}); });
testWidgets('Row with default main axis parameters', (WidgetTester tester) async { testWidgets('Row with default main axis parameters', (WidgetTester tester) async {
final Key rowKey = new Key('row'); final Key rowKey = const Key('row');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisSize.max so the Row should be as wide as the test: 800.
// Default is MainAxisAlignment.start so children so the children's // Default is MainAxisAlignment.start so children so the children's
...@@ -100,9 +100,9 @@ void main() { ...@@ -100,9 +100,9 @@ void main() {
}); });
testWidgets('Row with MainAxisAlignment.center', (WidgetTester tester) async { testWidgets('Row with MainAxisAlignment.center', (WidgetTester tester) async {
final Key rowKey = new Key('row'); final Key rowKey = const Key('row');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
// Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisSize.max so the Row should be as wide as the test: 800.
// The 100x100 children's left edges should be at 300, 400 // The 100x100 children's left edges should be at 300, 400
...@@ -138,10 +138,10 @@ void main() { ...@@ -138,10 +138,10 @@ void main() {
}); });
testWidgets('Row with MainAxisAlignment.end', (WidgetTester tester) async { testWidgets('Row with MainAxisAlignment.end', (WidgetTester tester) async {
final Key rowKey = new Key('row'); final Key rowKey = const Key('row');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisSize.max so the Row should be as wide as the test: 800.
// The 100x100 children's left edges should be at 500, 600, 700. // The 100x100 children's left edges should be at 500, 600, 700.
...@@ -184,10 +184,10 @@ void main() { ...@@ -184,10 +184,10 @@ void main() {
}); });
testWidgets('Row with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { testWidgets('Row with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
final Key rowKey = new Key('row'); final Key rowKey = const Key('row');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisSize.max so the Row should be as wide as the test: 800.
// The 100x100 children's left edges should be at 0, 350, 700 // The 100x100 children's left edges should be at 0, 350, 700
...@@ -230,11 +230,11 @@ void main() { ...@@ -230,11 +230,11 @@ void main() {
}); });
testWidgets('Row with MainAxisAlignment.spaceAround', (WidgetTester tester) async { testWidgets('Row with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
final Key rowKey = new Key('row'); final Key rowKey = const Key('row');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
final Key child3Key = new Key('child3'); final Key child3Key = const Key('child3');
// Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisSize.max so the Row should be as wide as the test: 800.
// The 100x100 children's left edges should be at 50, 250, 450, 650 // The 100x100 children's left edges should be at 50, 250, 450, 650
...@@ -284,10 +284,10 @@ void main() { ...@@ -284,10 +284,10 @@ void main() {
}); });
testWidgets('Row with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { testWidgets('Row with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
final Key rowKey = new Key('row'); final Key rowKey = const Key('row');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
final Key child2Key = new Key('child2'); final Key child2Key = const Key('child2');
// Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisSize.max so the Row should be as wide as the test: 800.
// The 200x100 children's left edges should be at 50, 300, 550 // The 200x100 children's left edges should be at 50, 300, 550
...@@ -330,9 +330,9 @@ void main() { ...@@ -330,9 +330,9 @@ void main() {
}); });
testWidgets('Row and MainAxisSize.min', (WidgetTester tester) async { testWidgets('Row and MainAxisSize.min', (WidgetTester tester) async {
final Key rowKey = new Key('rowKey'); final Key rowKey = const Key('rowKey');
final Key child0Key = new Key('child0'); final Key child0Key = const Key('child0');
final Key child1Key = new Key('child1'); final Key child1Key = const Key('child1');
// Row with MainAxisSize.min without flexible children shrink wraps. // Row with MainAxisSize.min without flexible children shrink wraps.
// Row's width should be 250, children should be at 0, 100. // Row's width should be 250, children should be at 0, 100.
...@@ -368,7 +368,7 @@ void main() { ...@@ -368,7 +368,7 @@ void main() {
}); });
testWidgets('Row MainAxisSize.min layout at zero size', (WidgetTester tester) async { testWidgets('Row MainAxisSize.min layout at zero size', (WidgetTester tester) async {
final Key childKey = new Key('childKey'); final Key childKey = const Key('childKey');
await tester.pumpWidget(new Center( await tester.pumpWidget(new Center(
child: new Container( child: new Container(
......
...@@ -45,7 +45,7 @@ void main() { ...@@ -45,7 +45,7 @@ void main() {
expect(realOffset(), equals(controller.offset)); expect(realOffset(), equals(controller.offset));
await tester.pumpWidget(new ListView( await tester.pumpWidget(new ListView(
key: new Key('second'), key: const Key('second'),
controller: controller, controller: controller,
children: kStates.map<Widget>((String state) { children: kStates.map<Widget>((String state) {
return new Container( return new Container(
...@@ -66,7 +66,7 @@ void main() { ...@@ -66,7 +66,7 @@ void main() {
ScrollController controller2 = new ScrollController(); ScrollController controller2 = new ScrollController();
await tester.pumpWidget(new ListView( await tester.pumpWidget(new ListView(
key: new Key('second'), key: const Key('second'),
controller: controller2, controller: controller2,
children: kStates.map<Widget>((String state) { children: kStates.map<Widget>((String state) {
return new Container( return new Container(
...@@ -84,7 +84,7 @@ void main() { ...@@ -84,7 +84,7 @@ void main() {
expect(() => controller.animateTo(132.0, duration: const Duration(milliseconds: 300), curve: Curves.ease), throws); expect(() => controller.animateTo(132.0, duration: const Duration(milliseconds: 300), curve: Curves.ease), throws);
await tester.pumpWidget(new ListView( await tester.pumpWidget(new ListView(
key: new Key('second'), key: const Key('second'),
controller: controller2, controller: controller2,
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
children: kStates.map<Widget>((String state) { children: kStates.map<Widget>((String state) {
......
...@@ -27,7 +27,7 @@ void main() { ...@@ -27,7 +27,7 @@ void main() {
}); });
testWidgets('Can change position data', (WidgetTester tester) async { testWidgets('Can change position data', (WidgetTester tester) async {
Key key = new Key('container'); Key key = const Key('container');
await tester.pumpWidget( await tester.pumpWidget(
new Stack( new Stack(
...@@ -82,7 +82,7 @@ void main() { ...@@ -82,7 +82,7 @@ void main() {
}); });
testWidgets('Can remove parent data', (WidgetTester tester) async { testWidgets('Can remove parent data', (WidgetTester tester) async {
Key key = new Key('container'); Key key = const Key('container');
Container container = new Container(key: key, width: 10.0, height: 10.0); Container container = new Container(key: key, width: 10.0, height: 10.0);
await tester.pumpWidget(new Stack(children: <Widget>[ new Positioned(left: 10.0, child: container) ])); await tester.pumpWidget(new Stack(children: <Widget>[ new Positioned(left: 10.0, child: container) ]));
...@@ -110,8 +110,8 @@ void main() { ...@@ -110,8 +110,8 @@ void main() {
}); });
testWidgets('Can align non-positioned children', (WidgetTester tester) async { testWidgets('Can align non-positioned children', (WidgetTester tester) async {
Key child0Key = new Key('child0'); Key child0Key = const Key('child0');
Key child1Key = new Key('child1'); Key child1Key = const Key('child1');
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Center(
...@@ -173,7 +173,7 @@ void main() { ...@@ -173,7 +173,7 @@ void main() {
}); });
testWidgets('Can hit test an IndexedStack', (WidgetTester tester) async { testWidgets('Can hit test an IndexedStack', (WidgetTester tester) async {
Key key = new Key('indexedStack'); Key key = const Key('indexedStack');
int itemCount = 3; int itemCount = 3;
List<int> itemsTapped; List<int> itemsTapped;
...@@ -197,7 +197,7 @@ void main() { ...@@ -197,7 +197,7 @@ void main() {
}); });
testWidgets('Can set width and height', (WidgetTester tester) async { testWidgets('Can set width and height', (WidgetTester tester) async {
Key key = new Key('container'); Key key = const Key('container');
BoxDecoration kBoxDecoration = const BoxDecoration( BoxDecoration kBoxDecoration = const BoxDecoration(
backgroundColor: const Color(0xFF00FF00) backgroundColor: const Color(0xFF00FF00)
......
...@@ -58,7 +58,7 @@ void main() { ...@@ -58,7 +58,7 @@ void main() {
testWidgets('Don\'t rebuild subwidgets', (WidgetTester tester) async { testWidgets('Don\'t rebuild subwidgets', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new FlipWidget( new FlipWidget(
key: new Key('rebuild test'), key: const Key('rebuild test'),
left: new TestBuildCounter(), left: new TestBuildCounter(),
right: new DecoratedBox(decoration: kBoxDecorationB) right: new DecoratedBox(decoration: kBoxDecorationB)
) )
......
...@@ -45,8 +45,8 @@ class OuterContainerState extends State<OuterContainer> { ...@@ -45,8 +45,8 @@ class OuterContainerState extends State<OuterContainer> {
void main() { void main() {
testWidgets('resync stateful widget', (WidgetTester tester) async { testWidgets('resync stateful widget', (WidgetTester tester) async {
Key innerKey = new Key('inner'); Key innerKey = const Key('inner');
Key outerKey = new Key('outer'); Key outerKey = const Key('outer');
InnerWidget inner1 = new InnerWidget(key: innerKey); InnerWidget inner1 = new InnerWidget(key: innerKey);
InnerWidget inner2; InnerWidget inner2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment