From 00cbdb3800603bce7ddf699c935f80d1ff382059 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Fri, 10 Feb 2017 00:18:49 +0100 Subject: [PATCH] prefer const constructor (#8031) --- .../flutter/lib/src/material/snack_bar.dart | 2 +- .../flutter/lib/src/widgets/framework.dart | 2 +- .../flutter/test/material/drawer_test.dart | 2 +- .../flutter/test/material/scaffold_test.dart | 6 +- .../flutter/test/material/snack_bar_test.dart | 8 +-- packages/flutter/test/material/tabs_test.dart | 4 +- .../test/material/time_picker_test.dart | 2 +- .../user_accounts_drawer_header_test.dart | 8 +-- .../flutter/test/widgets/baseline_test.dart | 4 +- packages/flutter/test/widgets/block_test.dart | 2 +- .../test/widgets/box_decoration_test.dart | 4 +- .../flutter/test/widgets/column_test.dart | 60 ++++++++--------- .../test/widgets/ensure_visible_test.dart | 34 +++++----- .../flutter/test/widgets/heroes_test.dart | 6 +- .../flutter/test/widgets/hyperlink_test.dart | 2 +- packages/flutter/test/widgets/key_test.dart | 6 +- .../flutter/test/widgets/multichild_test.dart | 28 ++++---- .../flutter/test/widgets/navigator_test.dart | 2 +- .../widgets/overscroll_indicator_test.dart | 2 +- .../test/widgets/page_storage_test.dart | 6 +- .../test/widgets/reparent_state_test.dart | 2 +- packages/flutter/test/widgets/row_test.dart | 64 +++++++++---------- .../test/widgets/scroll_controller_test.dart | 6 +- packages/flutter/test/widgets/stack_test.dart | 12 ++-- .../test/widgets/stateful_component_test.dart | 2 +- .../widgets/stateful_components_test.dart | 4 +- 26 files changed, 140 insertions(+), 140 deletions(-) diff --git a/packages/flutter/lib/src/material/snack_bar.dart b/packages/flutter/lib/src/material/snack_bar.dart index 359787cb68..20283bb55e 100644 --- a/packages/flutter/lib/src/material/snack_bar.dart +++ b/packages/flutter/lib/src/material/snack_bar.dart @@ -232,7 +232,7 @@ class SnackBar extends StatelessWidget { child: new Semantics( container: true, child: new Dismissable( - key: new Key('dismissable'), + key: const Key('dismissable'), direction: DismissDirection.down, resizeDuration: null, onDismissed: (DismissDirection direction) { diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 816057ddd2..bce313b7cb 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -135,7 +135,7 @@ typedef void GlobalKeyRemoveListener(GlobalKey key); /// 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, /// for [StatefulWidget]s, a [State]. /// diff --git a/packages/flutter/test/material/drawer_test.dart b/packages/flutter/test/material/drawer_test.dart index 25d86ce986..03b4214b89 100644 --- a/packages/flutter/test/material/drawer_test.dart +++ b/packages/flutter/test/material/drawer_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Drawer control test', (WidgetTester tester) async { - final Key containerKey = new Key('container'); + final Key containerKey = const Key('container'); await tester.pumpWidget( new Scaffold( diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index fe2c2a3fd9..c3359d882a 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -44,7 +44,7 @@ void main() { testWidgets('Floating action animation', (WidgetTester tester) async { await tester.pumpWidget(new Scaffold( floatingActionButton: new FloatingActionButton( - key: new Key("one"), + key: const Key('one'), onPressed: null, child: new Text("1") ) @@ -54,7 +54,7 @@ void main() { await tester.pumpWidget(new Scaffold( floatingActionButton: new FloatingActionButton( - key: new Key("two"), + key: const Key('two'), onPressed: null, child: new Text("2") ) @@ -68,7 +68,7 @@ void main() { await tester.pumpWidget(new Scaffold( floatingActionButton: new FloatingActionButton( - key: new Key("one"), + key: const Key('one'), onPressed: null, child: new Text("1") ) diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index b7fde46a9d..c55eab3fb8 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; void main() { testWidgets('SnackBar control test', (WidgetTester tester) async { String helloSnackBar = 'Hello SnackBar'; - Key tapTarget = new Key('tap-target'); + Key tapTarget = const Key('tap-target'); await tester.pumpWidget(new MaterialApp( home: new Scaffold( body: new Builder( @@ -53,7 +53,7 @@ void main() { testWidgets('SnackBar twice test', (WidgetTester tester) async { int snackBarCount = 0; - Key tapTarget = new Key('tap-target'); + Key tapTarget = const Key('tap-target'); await tester.pumpWidget(new MaterialApp( home: new Scaffold( body: new Builder( @@ -128,7 +128,7 @@ void main() { testWidgets('SnackBar cancel test', (WidgetTester tester) async { int snackBarCount = 0; - Key tapTarget = new Key('tap-target'); + Key tapTarget = const Key('tap-target'); int time; ScaffoldFeatureController lastController; await tester.pumpWidget(new MaterialApp( @@ -214,7 +214,7 @@ void main() { testWidgets('SnackBar dismiss test', (WidgetTester tester) async { int snackBarCount = 0; - Key tapTarget = new Key('tap-target'); + Key tapTarget = const Key('tap-target'); await tester.pumpWidget(new MaterialApp( home: new Scaffold( body: new Builder( diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 7ebd80e815..cf926df7ed 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -168,7 +168,7 @@ void main() { testWidgets('Scrollable TabBar tap centers selected tab', (WidgetTester tester) async { List tabs = ['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)); TabController controller = DefaultTabController.of(tester.element(find.text('AAAAAA'))); expect(controller, isNotNull); @@ -189,7 +189,7 @@ void main() { testWidgets('TabBar can be scrolled independent of the selection', (WidgetTester tester) async { List tabs = ['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)); TabController controller = DefaultTabController.of(tester.element(find.text('AAAA'))); expect(controller, isNotNull); diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index 5b3b799b97..da56398273 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -38,7 +38,7 @@ Future startPicker(WidgetTester tester, ValueChanged onChanged await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged)); await tester.tap(find.text('X')); 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 finishPicker(WidgetTester tester) async { diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 5003fb3b4b..79a12d92fa 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -8,9 +8,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('UserAccountsDrawerHeader test', (WidgetTester tester) async { - final Key avatarA = new Key('A'); - final Key avatarC = new Key('C'); - final Key avatarD = new Key('D'); + final Key avatarA = const Key('A'); + final Key avatarC = const Key('C'); + final Key avatarD = const Key('D'); await tester.pumpWidget( new Material( @@ -146,7 +146,7 @@ void main() { )); expect(find.text('A'), findsOneWidget); - final Key avatarA = new Key('A'); + final Key avatarA = const Key('A'); await tester.pumpWidget(buildFrame( currentAccountPicture: new CircleAvatar(key: avatarA, child: new Text('A')), accountName: new Text('accountName'), diff --git a/packages/flutter/test/widgets/baseline_test.dart b/packages/flutter/test/widgets/baseline_test.dart index fa382bcb0e..1744941ffa 100644 --- a/packages/flutter/test/widgets/baseline_test.dart +++ b/packages/flutter/test/widgets/baseline_test.dart @@ -10,7 +10,7 @@ void main() { await tester.pumpWidget( new Center( child: new DefaultTextStyle( - style: new TextStyle( + style: const TextStyle( fontFamily: 'Ahem', fontSize: 100.0, ), @@ -28,7 +28,7 @@ void main() { baseline: 180.0, baselineType: TextBaseline.alphabetic, child: new DefaultTextStyle( - style: new TextStyle( + style: const TextStyle( fontFamily: 'Ahem', fontSize: 100.0, ), diff --git a/packages/flutter/test/widgets/block_test.dart b/packages/flutter/test/widgets/block_test.dart index 7e1090fc58..6fd513428b 100644 --- a/packages/flutter/test/widgets/block_test.dart +++ b/packages/flutter/test/widgets/block_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; -final Key blockKey = new Key('test'); +final Key blockKey = const Key('test'); void main() { testWidgets('Cannot scroll a non-overflowing block', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/box_decoration_test.dart b/packages/flutter/test/widgets/box_decoration_test.dart index a67f7ae5f9..bfc1f35073 100644 --- a/packages/flutter/test/widgets/box_decoration_test.dart +++ b/packages/flutter/test/widgets/box_decoration_test.dart @@ -23,7 +23,7 @@ void main() { }); testWidgets('Bordered Container insets its child', (WidgetTester tester) async { - Key key = new Key('outerContainer'); + Key key = const Key('outerContainer'); await tester.pumpWidget( new Center( child: new Container( @@ -42,7 +42,7 @@ void main() { testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async { // 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) { return new Center( child: new Container( diff --git a/packages/flutter/test/widgets/column_test.dart b/packages/flutter/test/widgets/column_test.dart index c12b8bd904..c61e93a136 100644 --- a/packages/flutter/test/widgets/column_test.dart +++ b/packages/flutter/test/widgets/column_test.dart @@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Column with one flexible child', (WidgetTester tester) async { - final Key columnKey = new Key('column'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key columnKey = const Key('column'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -54,10 +54,10 @@ void main() { }); testWidgets('Column with default main axis parameters', (WidgetTester tester) async { - final Key columnKey = new Key('column'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key columnKey = const Key('column'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -100,9 +100,9 @@ void main() { }); testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async { - final Key columnKey = new Key('column'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); + final Key columnKey = const Key('column'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); // 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 @@ -138,10 +138,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async { - final Key columnKey = new Key('column'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key columnKey = const Key('column'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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. @@ -184,10 +184,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { - final Key columnKey = new Key('column'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key columnKey = const Key('column'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -230,11 +230,11 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async { - final Key columnKey = new Key('column'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); - final Key child3Key = new Key('child3'); + final Key columnKey = const Key('column'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); + final Key child3Key = const Key('child3'); // 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 @@ -284,10 +284,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { - final Key columnKey = new Key('column'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key columnKey = const Key('column'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -330,7 +330,7 @@ void main() { }); 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. await tester.pumpWidget(new Center( @@ -363,7 +363,7 @@ void main() { }); 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( child: new Container( diff --git a/packages/flutter/test/widgets/ensure_visible_test.dart b/packages/flutter/test/widgets/ensure_visible_test.dart index e46eefa52f..2275ba6409 100644 --- a/packages/flutter/test/widgets/ensure_visible_test.dart +++ b/packages/flutter/test/widgets/ensure_visible_test.dart @@ -21,13 +21,13 @@ Widget buildSingleChildScrollView(Axis scrollDirection, { bool reverse: false }) child: new BlockBody( mainAxis: scrollDirection, children: [ - new Container(key: new ValueKey(0), width: 200.0, height: 200.0), - new Container(key: new ValueKey(1), width: 200.0, height: 200.0), - new Container(key: new ValueKey(2), width: 200.0, height: 200.0), - new Container(key: new ValueKey(3), width: 200.0, height: 200.0), - new Container(key: new ValueKey(4), width: 200.0, height: 200.0), - new Container(key: new ValueKey(5), width: 200.0, height: 200.0), - new Container(key: new ValueKey(6), width: 200.0, height: 200.0), + new Container(key: const ValueKey(0), width: 200.0, height: 200.0), + new Container(key: const ValueKey(1), width: 200.0, height: 200.0), + new Container(key: const ValueKey(2), width: 200.0, height: 200.0), + new Container(key: const ValueKey(3), width: 200.0, height: 200.0), + new Container(key: const ValueKey(4), width: 200.0, height: 200.0), + new Container(key: const ValueKey(5), width: 200.0, height: 200.0), + new Container(key: const ValueKey(6), width: 200.0, height: 200.0), ], ), ), @@ -45,13 +45,13 @@ Widget buildListView(Axis scrollDirection, { bool reverse: false, bool shrinkWra reverse: reverse, shrinkWrap: shrinkWrap, children: [ - new Container(key: new ValueKey(0), width: 200.0, height: 200.0), - new Container(key: new ValueKey(1), width: 200.0, height: 200.0), - new Container(key: new ValueKey(2), width: 200.0, height: 200.0), - new Container(key: new ValueKey(3), width: 200.0, height: 200.0), - new Container(key: new ValueKey(4), width: 200.0, height: 200.0), - new Container(key: new ValueKey(5), width: 200.0, height: 200.0), - new Container(key: new ValueKey(6), width: 200.0, height: 200.0), + new Container(key: const ValueKey(0), width: 200.0, height: 200.0), + new Container(key: const ValueKey(1), width: 200.0, height: 200.0), + new Container(key: const ValueKey(2), width: 200.0, height: 200.0), + new Container(key: const ValueKey(3), width: 200.0, height: 200.0), + new Container(key: const ValueKey(4), width: 200.0, height: 200.0), + new Container(key: const ValueKey(5), width: 200.0, height: 200.0), + new Container(key: const ValueKey(6), width: 200.0, height: 200.0), ], ), ), @@ -189,7 +189,7 @@ void main() { child: new Transform( transform: new Matrix4.rotationZ(math.PI), child: new Container( - key: new ValueKey(0), + key: const ValueKey(0), width: 100.0, height: 100.0, decoration: const BoxDecoration( @@ -391,7 +391,7 @@ void main() { viewportBuilder: (BuildContext context, ViewportOffset offset) { return new Viewport2( offset: offset, - center: new ValueKey(4), + center: const ValueKey(4), slivers: [ buildSliver(0), buildSliver(1), @@ -441,7 +441,7 @@ void main() { child: new Transform( transform: new Matrix4.rotationZ(math.PI), child: new Container( - key: new ValueKey(0), + key: const ValueKey(0), width: 100.0, height: 100.0, decoration: const BoxDecoration( diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 39da092455..473459d728 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -5,9 +5,9 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; -Key firstKey = new Key('first'); -Key secondKey = new Key('second'); -Key thirdKey = new Key('third'); +Key firstKey = const Key('first'); +Key secondKey = const Key('second'); +Key thirdKey = const Key('third'); final Map routes = { '/': (BuildContext context) => new Material( diff --git a/packages/flutter/test/widgets/hyperlink_test.dart b/packages/flutter/test/widgets/hyperlink_test.dart index 613a8b276c..61579879f5 100644 --- a/packages/flutter/test/widgets/hyperlink_test.dart +++ b/packages/flutter/test/widgets/hyperlink_test.dart @@ -20,7 +20,7 @@ void main() { didTapRight = true; }; - Key textKey = new Key('text'); + Key textKey = const Key('text'); await tester.pumpWidget( new Center( diff --git a/packages/flutter/test/widgets/key_test.dart b/packages/flutter/test/widgets/key_test.dart index a46bffb82d..199aa1df43 100644 --- a/packages/flutter/test/widgets/key_test.dart +++ b/packages/flutter/test/widgets/key_test.dart @@ -47,11 +47,11 @@ void main() { 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 ValueKey(true), hasOneLineDescription); + expect(const ValueKey(true), hasOneLineDescription); expect(new UniqueKey(), hasOneLineDescription); - expect(new ObjectKey(true), hasOneLineDescription); + expect(const ObjectKey(true), hasOneLineDescription); expect(new GlobalKey(), hasOneLineDescription); expect(new GlobalKey(debugLabel: 'hello'), hasOneLineDescription); - expect(new GlobalObjectKey(true), hasOneLineDescription); + expect(const GlobalObjectKey(true), hasOneLineDescription); }); } diff --git a/packages/flutter/test/widgets/multichild_test.dart b/packages/flutter/test/widgets/multichild_test.dart index 9fb992a770..0234f05387 100644 --- a/packages/flutter/test/widgets/multichild_test.dart +++ b/packages/flutter/test/widgets/multichild_test.dart @@ -61,7 +61,7 @@ void main() { new Stack( children: [ new DecoratedBox(decoration: kBoxDecorationA), - new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB), + new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB), new DecoratedBox(decoration: kBoxDecorationC), ] ) @@ -72,9 +72,9 @@ void main() { await tester.pumpWidget( new Stack( children: [ - new DecoratedBox(key: new Key('b'), decoration: kBoxDecorationB), + new DecoratedBox(key: const Key('b'), decoration: kBoxDecorationB), 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() { await tester.pumpWidget( new Stack( children: [ - new DecoratedBox(key: new Key('a'), decoration: kBoxDecorationA), + new DecoratedBox(key: const Key('a'), decoration: kBoxDecorationA), 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() { new Stack( children: [ new Container( - key: new Key('b'), + key: const Key('b'), child: new DecoratedBox(decoration: kBoxDecorationB) ), new Container( - key: new Key('a'), + key: const Key('a'), child: new DecoratedBox(decoration: kBoxDecorationA) ), ] @@ -210,11 +210,11 @@ void main() { new Stack( children: [ new Container( - key: new Key('a'), + key: const Key('a'), child: new DecoratedBox(decoration: kBoxDecorationA) ), new Container( - key: new Key('b'), + key: const Key('b'), child: new DecoratedBox(decoration: kBoxDecorationB) ), ] @@ -283,7 +283,7 @@ void main() { new Stack( children: [ new FlipWidget( - key: new Key('flip'), + key: const Key('flip'), left: new DecoratedBox(decoration: kBoxDecorationA), right: new DecoratedBox(decoration: kBoxDecorationB) ), @@ -294,9 +294,9 @@ void main() { await tester.pumpWidget( new Stack( children: [ - new DecoratedBox(key: new Key('c'), decoration: kBoxDecorationC), + new DecoratedBox(key: const Key('c'), decoration: kBoxDecorationC), new FlipWidget( - key: new Key('flip'), + key: const Key('flip'), left: new DecoratedBox(decoration: kBoxDecorationA), right: new DecoratedBox(decoration: kBoxDecorationB) ), @@ -315,11 +315,11 @@ void main() { new Stack( children: [ new FlipWidget( - key: new Key('flip'), + key: const Key('flip'), left: new DecoratedBox(decoration: kBoxDecorationA), right: new DecoratedBox(decoration: kBoxDecorationB) ), - new DecoratedBox(key: new Key('c'), decoration: kBoxDecorationC), + new DecoratedBox(key: const Key('c'), decoration: kBoxDecorationC), ] ) ); diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 46dc6f436e..e3d110bfb0 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -162,7 +162,7 @@ void main() { }); 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; Widget widget = new ThirdWidget( targetKey: targetKey, diff --git a/packages/flutter/test/widgets/overscroll_indicator_test.dart b/packages/flutter/test/widgets/overscroll_indicator_test.dart index 1ac040bd08..1184a2a209 100644 --- a/packages/flutter/test/widgets/overscroll_indicator_test.dart +++ b/packages/flutter/test/widgets/overscroll_indicator_test.dart @@ -206,7 +206,7 @@ void main() { new Container( width: 2000.0, height: 2000.0, - decoration: new BoxDecoration( + decoration: const BoxDecoration( backgroundColor: const Color(0xFF00FF00), ), ), diff --git a/packages/flutter/test/widgets/page_storage_test.dart b/packages/flutter/test/widgets/page_storage_test.dart index f43e6f2ecd..5e315d338f 100644 --- a/packages/flutter/test/widgets/page_storage_test.dart +++ b/packages/flutter/test/widgets/page_storage_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; void main() { testWidgets('PageStorage read and write', (WidgetTester tester) async { - final Key builderKey = new Key('builderKey'); + final Key builderKey = const Key('builderKey'); StateSetter setState; int storedValue = 0; @@ -56,7 +56,7 @@ void main() { ); } - Key key = new Key('Key one'); + Key key = const Key('Key one'); await tester.pumpWidget(buildWidthKey(key)); Element builderElement = tester.element(find.byKey(key)); expect(PageStorage.of(builderElement), isNotNull); @@ -65,7 +65,7 @@ void main() { // 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)); builderElement = tester.element(find.byKey(key)); expect(PageStorage.of(builderElement), isNotNull); diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index ec1572c076..8c6f120377 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -199,7 +199,7 @@ void main() { itemExtent: 100.0, children: [ new Container( - key: new Key('container'), + key: const Key('container'), height: 100.0, child: new StateMarker(key: key), ), diff --git a/packages/flutter/test/widgets/row_test.dart b/packages/flutter/test/widgets/row_test.dart index 2c4ddf2d22..7a7b3c7c89 100644 --- a/packages/flutter/test/widgets/row_test.dart +++ b/packages/flutter/test/widgets/row_test.dart @@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Row with one Flexible child', (WidgetTester tester) async { - final Key rowKey = new Key('row'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key rowKey = const Key('row'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -54,10 +54,10 @@ void main() { }); testWidgets('Row with default main axis parameters', (WidgetTester tester) async { - final Key rowKey = new Key('row'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key rowKey = const Key('row'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -100,9 +100,9 @@ void main() { }); testWidgets('Row with MainAxisAlignment.center', (WidgetTester tester) async { - final Key rowKey = new Key('row'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); + final Key rowKey = const Key('row'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); // 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 @@ -138,10 +138,10 @@ void main() { }); testWidgets('Row with MainAxisAlignment.end', (WidgetTester tester) async { - final Key rowKey = new Key('row'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key rowKey = const Key('row'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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. @@ -184,10 +184,10 @@ void main() { }); testWidgets('Row with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { - final Key rowKey = new Key('row'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key rowKey = const Key('row'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -230,11 +230,11 @@ void main() { }); testWidgets('Row with MainAxisAlignment.spaceAround', (WidgetTester tester) async { - final Key rowKey = new Key('row'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); - final Key child3Key = new Key('child3'); + final Key rowKey = const Key('row'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); + final Key child3Key = const Key('child3'); // 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 @@ -284,10 +284,10 @@ void main() { }); testWidgets('Row with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { - final Key rowKey = new Key('row'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); - final Key child2Key = new Key('child2'); + final Key rowKey = const Key('row'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); + final Key child2Key = const Key('child2'); // 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 @@ -330,9 +330,9 @@ void main() { }); testWidgets('Row and MainAxisSize.min', (WidgetTester tester) async { - final Key rowKey = new Key('rowKey'); - final Key child0Key = new Key('child0'); - final Key child1Key = new Key('child1'); + final Key rowKey = const Key('rowKey'); + final Key child0Key = const Key('child0'); + final Key child1Key = const Key('child1'); // Row with MainAxisSize.min without flexible children shrink wraps. // Row's width should be 250, children should be at 0, 100. @@ -368,7 +368,7 @@ void main() { }); 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( child: new Container( diff --git a/packages/flutter/test/widgets/scroll_controller_test.dart b/packages/flutter/test/widgets/scroll_controller_test.dart index 58249a7726..ee09fddbc8 100644 --- a/packages/flutter/test/widgets/scroll_controller_test.dart +++ b/packages/flutter/test/widgets/scroll_controller_test.dart @@ -45,7 +45,7 @@ void main() { expect(realOffset(), equals(controller.offset)); await tester.pumpWidget(new ListView( - key: new Key('second'), + key: const Key('second'), controller: controller, children: kStates.map((String state) { return new Container( @@ -66,7 +66,7 @@ void main() { ScrollController controller2 = new ScrollController(); await tester.pumpWidget(new ListView( - key: new Key('second'), + key: const Key('second'), controller: controller2, children: kStates.map((String state) { return new Container( @@ -84,7 +84,7 @@ void main() { expect(() => controller.animateTo(132.0, duration: const Duration(milliseconds: 300), curve: Curves.ease), throws); await tester.pumpWidget(new ListView( - key: new Key('second'), + key: const Key('second'), controller: controller2, physics: const BouncingScrollPhysics(), children: kStates.map((String state) { diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index dd1bddf8bd..0058b4ca50 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -27,7 +27,7 @@ void main() { }); testWidgets('Can change position data', (WidgetTester tester) async { - Key key = new Key('container'); + Key key = const Key('container'); await tester.pumpWidget( new Stack( @@ -82,7 +82,7 @@ void main() { }); 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); await tester.pumpWidget(new Stack(children: [ new Positioned(left: 10.0, child: container) ])); @@ -110,8 +110,8 @@ void main() { }); testWidgets('Can align non-positioned children', (WidgetTester tester) async { - Key child0Key = new Key('child0'); - Key child1Key = new Key('child1'); + Key child0Key = const Key('child0'); + Key child1Key = const Key('child1'); await tester.pumpWidget( new Center( @@ -173,7 +173,7 @@ void main() { }); testWidgets('Can hit test an IndexedStack', (WidgetTester tester) async { - Key key = new Key('indexedStack'); + Key key = const Key('indexedStack'); int itemCount = 3; List itemsTapped; @@ -197,7 +197,7 @@ void main() { }); testWidgets('Can set width and height', (WidgetTester tester) async { - Key key = new Key('container'); + Key key = const Key('container'); BoxDecoration kBoxDecoration = const BoxDecoration( backgroundColor: const Color(0xFF00FF00) diff --git a/packages/flutter/test/widgets/stateful_component_test.dart b/packages/flutter/test/widgets/stateful_component_test.dart index 005ccf5fff..0e325fc8b9 100644 --- a/packages/flutter/test/widgets/stateful_component_test.dart +++ b/packages/flutter/test/widgets/stateful_component_test.dart @@ -58,7 +58,7 @@ void main() { testWidgets('Don\'t rebuild subwidgets', (WidgetTester tester) async { await tester.pumpWidget( new FlipWidget( - key: new Key('rebuild test'), + key: const Key('rebuild test'), left: new TestBuildCounter(), right: new DecoratedBox(decoration: kBoxDecorationB) ) diff --git a/packages/flutter/test/widgets/stateful_components_test.dart b/packages/flutter/test/widgets/stateful_components_test.dart index 99ebce4ac2..7bd8d5b084 100644 --- a/packages/flutter/test/widgets/stateful_components_test.dart +++ b/packages/flutter/test/widgets/stateful_components_test.dart @@ -45,8 +45,8 @@ class OuterContainerState extends State { void main() { testWidgets('resync stateful widget', (WidgetTester tester) async { - Key innerKey = new Key('inner'); - Key outerKey = new Key('outer'); + Key innerKey = const Key('inner'); + Key outerKey = const Key('outer'); InnerWidget inner1 = new InnerWidget(key: innerKey); InnerWidget inner2;