diff --git a/dev/devicelab/test/run_test.dart b/dev/devicelab/test/run_test.dart index db11eb7a35..61ab7768ed 100644 --- a/dev/devicelab/test/run_test.dart +++ b/dev/devicelab/test/run_test.dart @@ -10,7 +10,7 @@ import 'package:process/process.dart'; import 'package:test/test.dart'; void main() { - final ProcessManager processManager = const LocalProcessManager(); + const ProcessManager processManager = const LocalProcessManager(); group('run.dart script', () { Future runScript(List testNames) async { diff --git a/dev/tools/dartdoc.dart b/dev/tools/dartdoc.dart index fabc95b294..3a5ddada5a 100644 --- a/dev/tools/dartdoc.dart +++ b/dev/tools/dartdoc.dart @@ -256,7 +256,7 @@ void addHtmlBaseToIndex() { } void putRedirectInOldIndexLocation() { - final String metaTag = ''; + const String metaTag = ''; new File('$kDocRoot/flutter/index.html').writeAsStringSync(metaTag); } diff --git a/dev/tools/gen_localizations.dart b/dev/tools/gen_localizations.dart index 948d7b545f..05fcc5610f 100644 --- a/dev/tools/gen_localizations.dart +++ b/dev/tools/gen_localizations.dart @@ -271,7 +271,7 @@ void main(List rawArgs) { validateLocalizations(localeToResources, localeToResourceAttributes) ); - final String regenerate = 'dart dev/tools/gen_localizations.dart --overwrite'; + const String regenerate = 'dart dev/tools/gen_localizations.dart --overwrite'; final StringBuffer buffer = new StringBuffer(); buffer.writeln(outputHeader.replaceFirst('@(regenerate)', regenerate)); buffer.write(generateTranslationBundles()); diff --git a/dev/tools/vitool/test/vitool_test.dart b/dev/tools/vitool/test/vitool_test.dart index b915ca92d2..73a89d0550 100644 --- a/dev/tools/vitool/test/vitool_test.dart +++ b/dev/tools/vitool/test/vitool_test.dart @@ -210,7 +210,7 @@ void main() { group('create PathAnimation', () { test('single path', () { - final List frameData = const [ + const List frameData = const [ const FrameData( const Point(10.0, 10.0), const [ @@ -240,7 +240,7 @@ void main() { }); test('multiple paths', () { - final List frameData = const [ + const List frameData = const [ const FrameData( const Point(10.0, 10.0), const [ @@ -283,7 +283,7 @@ void main() { }); test('multiple frames', () { - final List frameData = const [ + const List frameData = const [ const FrameData( const Point(10.0, 10.0), const [ @@ -326,7 +326,7 @@ void main() { group('create Animation', () { test('multiple paths', () { - final List frameData = const [ + const List frameData = const [ const FrameData( const Point(10.0, 10.0), const [ @@ -374,7 +374,7 @@ void main() { group('toDart', () { test('_PathMoveTo', () { - final PathCommandAnimation command = const PathCommandAnimation( + const PathCommandAnimation command = const PathCommandAnimation( 'M', const >>[ const >[ @@ -396,7 +396,7 @@ void main() { }); test('_PathLineTo', () { - final PathCommandAnimation command = const PathCommandAnimation( + const PathCommandAnimation command = const PathCommandAnimation( 'L', const >>[ const >[ @@ -418,7 +418,7 @@ void main() { }); test('_PathCubicTo', () { - final PathCommandAnimation command = const PathCommandAnimation( + const PathCommandAnimation command = const PathCommandAnimation( 'C', const >>[ const >[ @@ -456,7 +456,7 @@ void main() { }); test('_PathClose', () { - final PathCommandAnimation command = const PathCommandAnimation( + const PathCommandAnimation command = const PathCommandAnimation( 'Z', const >>[], ); @@ -469,7 +469,7 @@ void main() { }); test('Unsupported path command', () { - final PathCommandAnimation command = const PathCommandAnimation( + const PathCommandAnimation command = const PathCommandAnimation( 'h', const >>[], ); @@ -481,7 +481,7 @@ void main() { }); test('_PathFrames', () { - final PathAnimation pathAnimation = const PathAnimation( + const PathAnimation pathAnimation = const PathAnimation( const [ const PathCommandAnimation('M', const >>[ const >[ @@ -524,7 +524,7 @@ void main() { }); test('Animation', () { - final Animation animation = const Animation( + const Animation animation = const Animation( const Point(48.0, 48.0), const [ const PathAnimation( diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index 9517a51a5e..05a08e1c86 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart @@ -113,8 +113,8 @@ class _HeadingLayout extends MultiChildLayoutDelegate { final double imageWidth = (landscape ? size.width / 2.0 : size.width) - margin * 2.0; final BoxConstraints imageConstraints = new BoxConstraints(maxHeight: 224.0, maxWidth: imageWidth); final Size imageSize = layoutChild(image, imageConstraints); - final double imageY = 0.0; - positionChild(image, new Offset(margin, imageY)); + const double imageY = 0.0; + positionChild(image, const Offset(margin, imageY)); final double productWidth = landscape ? size.width / 2.0 : size.width - margin; final BoxConstraints productConstraints = new BoxConstraints(maxWidth: productWidth); diff --git a/examples/flutter_gallery/test/smoke_test.dart b/examples/flutter_gallery/test/smoke_test.dart index 197885bce5..e06afbb28a 100644 --- a/examples/flutter_gallery/test/smoke_test.dart +++ b/examples/flutter_gallery/test/smoke_test.dart @@ -32,7 +32,7 @@ void reportToStringError(String name, String route, int lineNumber, List // If you're on line 12, then it has index 11. // If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12. // That's (lineNumber-1)-margin .. (lineNumber-1)+margin, or lineNumber-(margin+1) .. lineNumber+(margin-1) - final int margin = 5; + const int margin = 5; final int firstLine = math.max(0, lineNumber - margin); final int lastLine = math.min(lines.length, lineNumber + margin); print('$name : $route : line $lineNumber of ${lines.length} : $message; nearby lines were:\n ${lines.sublist(firstLine, lastLine).join("\n ")}'); diff --git a/examples/stocks/lib/stock_arrow.dart b/examples/stocks/lib/stock_arrow.dart index bb6a5a4241..27c9cdd2ac 100644 --- a/examples/stocks/lib/stock_arrow.dart +++ b/examples/stocks/lib/stock_arrow.dart @@ -23,7 +23,7 @@ class StockArrowPainter extends CustomPainter { final double centerY = padding + r; // Draw the arrow. - final double w = 8.0; + const double w = 8.0; double h = 5.0; double arrowY; if (percentChange < 0.0) { @@ -58,7 +58,7 @@ class StockArrow extends StatelessWidget { final double percentChange; int _colorIndexForPercentChange(double percentChange) { - final double maxPercent = 10.0; + const double maxPercent = 10.0; final double normalizedPercentChange = math.min(percentChange.abs(), maxPercent) / maxPercent; return 100 + (normalizedPercentChange * 8.0).floor() * 100; } diff --git a/examples/stocks/lib/stock_data.dart b/examples/stocks/lib/stock_data.dart index 57243b672f..0c2d7ad29f 100644 --- a/examples/stocks/lib/stock_data.dart +++ b/examples/stocks/lib/stock_data.dart @@ -85,7 +85,7 @@ class StockData extends ChangeNotifier { _end(); return; } - final JsonDecoder decoder = const JsonDecoder(); + const JsonDecoder decoder = const JsonDecoder(); add(decoder.convert(json)); if (_nextChunk < _kChunkCount) { _fetchNextChunk(); diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index 93b52e1c3e..bb2f22d426 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -918,7 +918,7 @@ abstract class DiagnosticsNode { if (i > 0) builder.write(config.propertySeparator); - final int kWrapWidth = 65; + const int kWrapWidth = 65; if (property.style != DiagnosticsTreeStyle.singleLine) { final TextTreeConfiguration propertyStyle = property.textTreeConfiguration; builder.writeRaw(property.toStringDeep( diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index 5f65e0c8c0..5865e503d1 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -210,9 +210,9 @@ class _RenderCheckbox extends RenderToggleable { ..style = PaintingStyle.stroke ..strokeWidth = _kStrokeWidth; final Path path = new Path(); - final Offset start = const Offset(_kEdgeSize * 0.15, _kEdgeSize * 0.45); - final Offset mid = const Offset(_kEdgeSize * 0.4, _kEdgeSize * 0.7); - final Offset end = const Offset(_kEdgeSize * 0.85, _kEdgeSize * 0.25); + const Offset start = const Offset(_kEdgeSize * 0.15, _kEdgeSize * 0.45); + const Offset mid = const Offset(_kEdgeSize * 0.4, _kEdgeSize * 0.7); + const Offset end = const Offset(_kEdgeSize * 0.85, _kEdgeSize * 0.25); final Offset drawStart = Offset.lerp(start, mid, 1.0 - value); final Offset drawEnd = Offset.lerp(mid, end, value); path.moveTo(offsetX + drawStart.dx, offsetY + drawStart.dy); diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index d9761d8fb6..91a2394879 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -401,7 +401,7 @@ class DataTable extends StatelessWidget { down: sorted ? ascending : null, duration: _kSortArrowAnimationDuration, ); - final Widget arrowPadding = const SizedBox(width: _kSortArrowPadding); + const Widget arrowPadding = const SizedBox(width: _kSortArrowPadding); label = new Row( textDirection: numeric ? TextDirection.rtl : null, children: [ label, arrowPadding, arrow ], @@ -453,7 +453,7 @@ class DataTable extends StatelessWidget { }) { final bool isLightTheme = Theme.of(context).brightness == Brightness.light; if (showEditIcon) { - final Widget icon = const Icon(Icons.edit, size: 18.0); + const Widget icon = const Icon(Icons.edit, size: 18.0); label = new Expanded(child: label); label = new Row( textDirection: numeric ? TextDirection.rtl : null, diff --git a/packages/flutter/lib/src/material/flexible_space_bar.dart b/packages/flutter/lib/src/material/flexible_space_bar.dart index aa67b48ea3..e375894cf7 100644 --- a/packages/flutter/lib/src/material/flexible_space_bar.dart +++ b/packages/flutter/lib/src/material/flexible_space_bar.dart @@ -122,7 +122,7 @@ class _FlexibleSpaceBarState extends State { // background image if (widget.background != null) { final double fadeStart = math.max(0.0, 1.0 - kToolbarHeight / deltaExtent); - final double fadeEnd = 1.0; + const double fadeEnd = 1.0; assert(fadeStart <= fadeEnd); final double opacity = 1.0 - new Interval(fadeStart, fadeEnd).transform(t); final double parallax = new Tween(begin: 0.0, end: deltaExtent / 4.0).lerp(t); diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index b1bd87f265..04dd96645c 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -453,7 +453,7 @@ class FocusManager { @override String toString() { final String status = _haveScheduledUpdate ? ' UPDATE SCHEDULED' : ''; - final String indent = ' '; + const String indent = ' '; return '${describeIdentity(this)}$status\n' '${indent}currentFocus: $_currentFocus\n' '${rootScope.toStringDeep(prefixLineOne: indent, prefixOtherLines: indent)}'; diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 771fcc77dd..2b138823ac 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -954,7 +954,7 @@ class _InspectorOverlayLayer extends Layer { final Rect targetRect = MatrixUtils.transformRect( state.selected.transform, state.selected.rect); final Offset target = new Offset(targetRect.left, targetRect.center.dy); - final double offsetFromWidget = 9.0; + const double offsetFromWidget = 9.0; final double verticalOffset = (targetRect.height) / 2 + offsetFromWidget; _paintDescription(canvas, state.tooltip, state.textDirection, target, verticalOffset, size, targetRect); diff --git a/packages/flutter/test/animation/curves_test.dart b/packages/flutter/test/animation/curves_test.dart index 6403fce919..7af7305820 100644 --- a/packages/flutter/test/animation/curves_test.dart +++ b/packages/flutter/test/animation/curves_test.dart @@ -26,7 +26,7 @@ void main() { }); test('Threshold has a threshold', () { - final Curve step = const Threshold(0.25); + const Curve step = const Threshold(0.25); expect(step.transform(0.0), 0.0); expect(step.transform(0.24), 0.0); expect(step.transform(0.25), 1.0); diff --git a/packages/flutter/test/cupertino/button_test.dart b/packages/flutter/test/cupertino/button_test.dart index 6f2e1f18fe..246d21e02b 100644 --- a/packages/flutter/test/cupertino/button_test.dart +++ b/packages/flutter/test/cupertino/button_test.dart @@ -33,9 +33,9 @@ void main() { }); testWidgets('Minimum size parameter', (WidgetTester tester) async { - final double minSize = 60.0; + const double minSize = 60.0; await tester.pumpWidget( - boilerplate(child: new CupertinoButton( + boilerplate(child: const CupertinoButton( child: const Text('X', style: testStyle), onPressed: null, minSize: minSize, @@ -45,7 +45,7 @@ void main() { expect( buttonBox.size, // 1 10px character + 16px * 2 is smaller than defined 60.0px minimum - new Size.square(minSize), + const Size.square(minSize), ); }); @@ -150,7 +150,7 @@ void main() { }); testWidgets('pressedOpacity parameter', (WidgetTester tester) async { - final double pressedOpacity = 0.5; + const double pressedOpacity = 0.5; await tester.pumpWidget(boilerplate(child: new CupertinoButton( pressedOpacity: pressedOpacity, child: const Text('Tap me'), diff --git a/packages/flutter/test/cupertino/scaffold_test.dart b/packages/flutter/test/cupertino/scaffold_test.dart index 602f9ad72b..eceea198f6 100644 --- a/packages/flutter/test/cupertino/scaffold_test.dart +++ b/packages/flutter/test/cupertino/scaffold_test.dart @@ -34,7 +34,7 @@ void main() { }); testWidgets('Contents are between opaque bars', (WidgetTester tester) async { - final Center page1Center = const Center(); + const Center page1Center = const Center(); await tester.pumpWidget( new WidgetsApp( @@ -59,7 +59,7 @@ void main() { ), tabBuilder: (BuildContext context, int index) { return index == 0 - ? new CupertinoPageScaffold( + ? const CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( backgroundColor: CupertinoColors.white, middle: const Text('Title'), diff --git a/packages/flutter/test/engine/color_test.dart b/packages/flutter/test/engine/color_test.dart index 888cbd7d1a..cb7c51e462 100644 --- a/packages/flutter/test/engine/color_test.dart +++ b/packages/flutter/test/engine/color_test.dart @@ -8,7 +8,7 @@ import 'package:test/test.dart'; void main() { test('color accessors should work', () { - final Color foo = const Color(0x12345678); + const Color foo = const Color(0x12345678); expect(foo.alpha, equals(0x12)); expect(foo.red, equals(0x34)); expect(foo.green, equals(0x56)); @@ -16,7 +16,7 @@ void main() { }); test('paint set to black', () { - final Color c = const Color(0x00000000); + const Color c = const Color(0x00000000); final Paint p = new Paint(); p.color = c; expect(c.toString(), equals('Color(0x00000000)')); @@ -24,7 +24,7 @@ void main() { test('color created with out of bounds value', () { try { - final Color c = const Color(0x100 << 24); + const Color c = const Color(0x100 << 24); final Paint p = new Paint(); p.color = c; } catch (e) { @@ -34,7 +34,7 @@ void main() { test('color created with wildly out of bounds value', () { try { - final Color c = const Color(1 << 1000000); + const Color c = const Color(1 << 1000000); final Paint p = new Paint(); p.color = c; } catch (e) { diff --git a/packages/flutter/test/foundation/diagnostics_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart index cc015a092d..794de1c170 100644 --- a/packages/flutter/test/foundation/diagnostics_test.dart +++ b/packages/flutter/test/foundation/diagnostics_test.dart @@ -1332,7 +1332,7 @@ void main() { test('color property test', () { // Add more tests if colorProperty becomes more than a wrapper around // objectProperty. - final Color color = const Color.fromARGB(255, 255, 255, 255); + const Color color = const Color.fromARGB(255, 255, 255, 255); final DiagnosticsProperty simple = new DiagnosticsProperty( 'name', color, diff --git a/packages/flutter/test/gestures/debug_test.dart b/packages/flutter/test/gestures/debug_test.dart index fdf6dcd061..3c9ecf9f99 100644 --- a/packages/flutter/test/gestures/debug_test.dart +++ b/packages/flutter/test/gestures/debug_test.dart @@ -149,7 +149,7 @@ void main() { test('TapGestureRecognizer _sentTapDown toString', () { final TapGestureRecognizer tap = new TapGestureRecognizer(); expect(tap.toString(), equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready)')); - final PointerEvent event = const PointerDownEvent(pointer: 1, position: const Offset(10.0, 10.0)); + const PointerEvent event = const PointerDownEvent(pointer: 1, position: const Offset(10.0, 10.0)); tap.addPointer(event); tap.didExceedDeadline(); expect(tap.toString(), equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: possible, sent tap down)')); diff --git a/packages/flutter/test/gestures/gesture_binding_test.dart b/packages/flutter/test/gestures/gesture_binding_test.dart index 1c97204cf0..8af8b290d2 100644 --- a/packages/flutter/test/gestures/gesture_binding_test.dart +++ b/packages/flutter/test/gestures/gesture_binding_test.dart @@ -32,7 +32,7 @@ void main() { setUp(ensureTestGestureBinding); test('Pointer tap events', () { - final ui.PointerDataPacket packet = const ui.PointerDataPacket( + const ui.PointerDataPacket packet = const ui.PointerDataPacket( data: const [ const ui.PointerData(change: ui.PointerChange.down), const ui.PointerData(change: ui.PointerChange.up), @@ -49,7 +49,7 @@ void main() { }); test('Pointer move events', () { - final ui.PointerDataPacket packet = const ui.PointerDataPacket( + const ui.PointerDataPacket packet = const ui.PointerDataPacket( data: const [ const ui.PointerData(change: ui.PointerChange.down), const ui.PointerData(change: ui.PointerChange.move), @@ -95,7 +95,7 @@ void main() { }); test('Pointer cancel events', () { - final ui.PointerDataPacket packet = const ui.PointerDataPacket( + const ui.PointerDataPacket packet = const ui.PointerDataPacket( data: const [ const ui.PointerData(change: ui.PointerChange.down), const ui.PointerData(change: ui.PointerChange.cancel), @@ -112,7 +112,7 @@ void main() { }); test('Can cancel pointers', () { - final ui.PointerDataPacket packet = const ui.PointerDataPacket( + const ui.PointerDataPacket packet = const ui.PointerDataPacket( data: const [ const ui.PointerData(change: ui.PointerChange.down), const ui.PointerData(change: ui.PointerChange.up), @@ -133,7 +133,7 @@ void main() { }); test('Can expand add and hover pointers', () { - final ui.PointerDataPacket packet = const ui.PointerDataPacket( + const ui.PointerDataPacket packet = const ui.PointerDataPacket( data: const [ const ui.PointerData(change: ui.PointerChange.add, device: 24), const ui.PointerData(change: ui.PointerChange.hover, device: 24), diff --git a/packages/flutter/test/gestures/team_test.dart b/packages/flutter/test/gestures/team_test.dart index c6ad758f0a..5fd762537f 100644 --- a/packages/flutter/test/gestures/team_test.dart +++ b/packages/flutter/test/gestures/team_test.dart @@ -28,7 +28,7 @@ void main() { tap.onTap = () { log.add('tap'); }; void test(Offset delta) { - final Offset origin = const Offset(10.0, 10.0); + const Offset origin = const Offset(10.0, 10.0); final TestPointer pointer = new TestPointer(5); final PointerDownEvent down = pointer.down(origin); horizontalDrag.addPointer(down); diff --git a/packages/flutter/test/gestures/velocity_tracker_test.dart b/packages/flutter/test/gestures/velocity_tracker_test.dart index ecc5513c4b..7a1fa911e8 100644 --- a/packages/flutter/test/gestures/velocity_tracker_test.dart +++ b/packages/flutter/test/gestures/velocity_tracker_test.dart @@ -19,7 +19,7 @@ bool _checkVelocity(Velocity actual, Offset expected) { } void main() { - final List expected = const [ + const List expected = const [ const Offset(219.5762939453125, 1304.6705322265625), const Offset(355.6900939941406, 967.1700439453125), const Offset(12.651158332824707, -36.9227180480957), @@ -49,8 +49,8 @@ void main() { }); test('Velocity control test', () { - final Velocity velocity1 = const Velocity(pixelsPerSecond: const Offset(7.0, 0.0)); - final Velocity velocity2 = const Velocity(pixelsPerSecond: const Offset(12.0, 0.0)); + const Velocity velocity1 = const Velocity(pixelsPerSecond: const Offset(7.0, 0.0)); + const Velocity velocity2 = const Velocity(pixelsPerSecond: const Offset(12.0, 0.0)); expect(velocity1, equals(const Velocity(pixelsPerSecond: const Offset(7.0, 0.0)))); expect(velocity1, isNot(equals(velocity2))); expect(velocity2 - velocity1, equals(const Velocity(pixelsPerSecond: const Offset(5.0, 0.0)))); diff --git a/packages/flutter/test/material/animated_icons_private_test.dart b/packages/flutter/test/material/animated_icons_private_test.dart index 5e5a24ef71..d92284cb80 100644 --- a/packages/flutter/test/material/animated_icons_private_test.dart +++ b/packages/flutter/test/material/animated_icons_private_test.dart @@ -46,7 +46,7 @@ class MockPath extends Mock implements ui.Path {} void main () { group('Interpolate points', () { test('- single point', () { - final List points = const [ + const List points = const [ const Offset(25.0, 1.0), ]; expect(_interpolate(points, 0.0, Offset.lerp), const Offset(25.0, 1.0)); @@ -55,7 +55,7 @@ void main () { }); test('- two points', () { - final List points = const [ + const List points = const [ const Offset(25.0, 1.0), const Offset(12.0, 12.0), ]; @@ -65,7 +65,7 @@ void main () { }); test('- three points', () { - final List points = const [ + const List points = const [ const Offset(25.0, 1.0), const Offset(12.0, 12.0), const Offset(23.0, 9.0), @@ -79,7 +79,7 @@ void main () { }); group('_AnimatedIconPainter', () { - final Size size = const Size(48.0, 48.0); + const Size size = const Size(48.0, 48.0); final MockCanvas mockCanvas = new MockCanvas(); List generatedPaths; final _UiPathFactory pathFactory = () { diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index c25777c5ae..0b7e60e249 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -627,7 +627,7 @@ void main() { expect(appBarIsVisible(tester), true); expect(appBarHeight(tester), 128.0); - final double initialAppBarHeight = 128.0; + const double initialAppBarHeight = 128.0; final double initialTabBarHeight = tabBarHeight(tester); // Scroll the not-pinned appbar, collapsing the expanded height. At this @@ -660,7 +660,7 @@ void main() { expect(appBarIsVisible(tester), true); expect(appBarHeight(tester), 128.0); - final double initialAppBarHeight = 128.0; + const double initialAppBarHeight = 128.0; final double initialTabBarHeight = tabBarHeight(tester); // Scroll the floating-pinned appbar, collapsing the expanded height. At this diff --git a/packages/flutter/test/material/arc_test.dart b/packages/flutter/test/material/arc_test.dart index 51f98a4143..3515416066 100644 --- a/packages/flutter/test/material/arc_test.dart +++ b/packages/flutter/test/material/arc_test.dart @@ -68,8 +68,8 @@ void main() { }); test('MaterialPointArcTween', () { - final Offset begin = const Offset(180.0, 110.0); - final Offset end = const Offset(37.0, 250.0); + const Offset begin = const Offset(180.0, 110.0); + const Offset end = const Offset(37.0, 250.0); MaterialPointArcTween tween = new MaterialPointArcTween(begin: begin, end: end); expect(tween.lerp(0.0), begin); diff --git a/packages/flutter/test/material/buttons_test.dart b/packages/flutter/test/material/buttons_test.dart index 1e15978fa2..e80977ce80 100644 --- a/packages/flutter/test/material/buttons_test.dart +++ b/packages/flutter/test/material/buttons_test.dart @@ -172,8 +172,8 @@ void main() { // This test is very similar to the '...explicit splashColor and highlightColor' test // in icon_button_test.dart. If you change this one, you may want to also change that one. testWidgets('MaterialButton with explicit splashColor and highlightColor', (WidgetTester tester) async { - final Color directSplashColor = const Color(0xFF000011); - final Color directHighlightColor = const Color(0xFF000011); + const Color directSplashColor = const Color(0xFF000011); + const Color directHighlightColor = const Color(0xFF000011); Widget buttonWidget = new Material( child: new Center( @@ -207,8 +207,8 @@ void main() { ..rrect(color: directHighlightColor) ); - final Color themeSplashColor1 = const Color(0xFF001100); - final Color themeHighlightColor1 = const Color(0xFF001100); + const Color themeSplashColor1 = const Color(0xFF001100); + const Color themeHighlightColor1 = const Color(0xFF001100); buttonWidget = new Material( child: new Center( @@ -238,8 +238,8 @@ void main() { ..rrect(color: themeHighlightColor1) ); - final Color themeSplashColor2 = const Color(0xFF002200); - final Color themeHighlightColor2 = const Color(0xFF002200); + const Color themeSplashColor2 = const Color(0xFF002200); + const Color themeHighlightColor2 = const Color(0xFF002200); await tester.pumpWidget( new Directionality( diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index c05eb8a07b..c10e4d22b5 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -178,13 +178,13 @@ void main() { }); testWidgets('Chip in row works ok', (WidgetTester tester) async { - final TextStyle style = const TextStyle(fontFamily: 'Ahem', fontSize: 10.0); + const TextStyle style = const TextStyle(fontFamily: 'Ahem', fontSize: 10.0); await tester.pumpWidget( new MaterialApp( home: new Material( child: new Row( - children: [ - new Chip(label: const Text('Test'), labelStyle: style), + children: const [ + const Chip(label: const Text('Test'), labelStyle: style), ], ), ), @@ -196,8 +196,8 @@ void main() { new MaterialApp( home: new Material( child: new Row( - children: [ - new Flexible(child: new Chip(label: const Text('Test'), labelStyle: style)), + children: const [ + const Flexible(child: const Chip(label: const Text('Test'), labelStyle: style)), ], ), ), @@ -209,8 +209,8 @@ void main() { new MaterialApp( home: new Material( child: new Row( - children: [ - new Expanded(child: new Chip(label: const Text('Test'), labelStyle: style)), + children: const [ + const Expanded(child: const Chip(label: const Text('Test'), labelStyle: style)), ], ), ), diff --git a/packages/flutter/test/material/colors_test.dart b/packages/flutter/test/material/colors_test.dart index 0d26b1c748..e9ccadfba3 100644 --- a/packages/flutter/test/material/colors_test.dart +++ b/packages/flutter/test/material/colors_test.dart @@ -11,7 +11,7 @@ const List accentKeys = const [100, 200, 400, 700]; void main() { test('MaterialColor basic functionality', () { - final MaterialColor color = const MaterialColor( + const MaterialColor color = const MaterialColor( 500, const { 50: const Color(50), diff --git a/packages/flutter/test/material/drawer_test.dart b/packages/flutter/test/material/drawer_test.dart index 50d483ae99..6efdfbdbc6 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 = const Key('container'); + const Key containerKey = const Key('container'); await tester.pumpWidget( new MaterialApp( diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index 3cf5692a61..c00a95ba4f 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -207,7 +207,7 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/12053 // Positions a DropdownButton at the left and right edges of the screen, // forcing it to be sized down to the viewport width - final String value = 'foo'; + const String value = 'foo'; final UniqueKey itemKey = new UniqueKey(); await tester.pumpWidget( new MaterialApp( @@ -220,7 +220,7 @@ void main() { new DropdownMenuItem( key: itemKey, value: value, - child: new Text(value), + child: const Text(value), ), ], onChanged: (_) {}, @@ -293,7 +293,7 @@ void main() { for (TextDirection textDirection in TextDirection.values) { testWidgets('Dropdown button aligns selected menu item ($textDirection)', (WidgetTester tester) async { final Key buttonKey = new UniqueKey(); - final String value = 'two'; + const String value = 'two'; Widget build() => buildFrame(buttonKey: buttonKey, value: value, textDirection: textDirection); @@ -339,7 +339,7 @@ void main() { testWidgets('Dropdown button with isDense:true aligns selected menu item', (WidgetTester tester) async { final Key buttonKey = new UniqueKey(); - final String value = 'two'; + const String value = 'two'; Widget build() => buildFrame(buttonKey: buttonKey, value: value, isDense: true); diff --git a/packages/flutter/test/material/expansion_tile_test.dart b/packages/flutter/test/material/expansion_tile_test.dart index 77d4c6d9f3..d35992f47a 100644 --- a/packages/flutter/test/material/expansion_tile_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -7,13 +7,13 @@ import 'package:flutter/widgets.dart'; import 'package:flutter/material.dart'; void main() { - final Color _dividerColor = const Color(0x1f333333); + const Color _dividerColor = const Color(0x1f333333); testWidgets('ExpansionTile initial state', (WidgetTester tester) async { final Key topKey = new UniqueKey(); - final Key expandedKey = const PageStorageKey('expanded'); - final Key collapsedKey = const PageStorageKey('collapsed'); - final Key defaultKey = const PageStorageKey('default'); + const Key expandedKey = const PageStorageKey('expanded'); + const Key collapsedKey = const PageStorageKey('collapsed'); + const Key defaultKey = const PageStorageKey('default'); final Key tileKey = new UniqueKey(); @@ -50,7 +50,7 @@ void main() { ) ] ), - new ExpansionTile( + const ExpansionTile( key: defaultKey, title: const Text('Default'), children: const [ diff --git a/packages/flutter/test/material/icon_button_test.dart b/packages/flutter/test/material/icon_button_test.dart index 53c75e5f5a..80181c0374 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -194,8 +194,8 @@ void main() { // This test is very similar to the '...explicit splashColor and highlightColor' test // in buttons_test.dart. If you change this one, you may want to also change that one. testWidgets('IconButton with explicit splashColor and highlightColor', (WidgetTester tester) async { - final Color directSplashColor = const Color(0xFF00000F); - final Color directHighlightColor = const Color(0xFF0000F0); + const Color directSplashColor = const Color(0xFF00000F); + const Color directHighlightColor = const Color(0xFF0000F0); Widget buttonWidget = wrap( child: new IconButton( @@ -225,8 +225,8 @@ void main() { ..circle(color: directHighlightColor) ); - final Color themeSplashColor1 = const Color(0xFF000F00); - final Color themeHighlightColor1 = const Color(0xFF00FF00); + const Color themeSplashColor1 = const Color(0xFF000F00); + const Color themeHighlightColor1 = const Color(0xFF00FF00); buttonWidget = wrap( child: new IconButton( @@ -252,8 +252,8 @@ void main() { ..circle(color: themeHighlightColor1) ); - final Color themeSplashColor2 = const Color(0xFF002200); - final Color themeHighlightColor2 = const Color(0xFF001100); + const Color themeSplashColor2 = const Color(0xFF002200); + const Color themeHighlightColor2 = const Color(0xFF001100); await tester.pumpWidget( new Theme( diff --git a/packages/flutter/test/material/ink_paint_test.dart b/packages/flutter/test/material/ink_paint_test.dart index 789b784007..5bec97828c 100644 --- a/packages/flutter/test/material/ink_paint_test.dart +++ b/packages/flutter/test/material/ink_paint_test.dart @@ -10,8 +10,8 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('The InkWell widget renders an ink splash', (WidgetTester tester) async { - final Color highlightColor = const Color(0xAAFF0000); - final Color splashColor = const Color(0xAA0000FF); + const Color highlightColor = const Color(0xAAFF0000); + const Color splashColor = const Color(0xAA0000FF); final BorderRadius borderRadius = new BorderRadius.circular(6.0); await tester.pumpWidget( @@ -52,8 +52,8 @@ void main() { }); testWidgets('The InkWell widget renders an ink ripple', (WidgetTester tester) async { - final Color highlightColor = const Color(0xAAFF0000); - final Color splashColor = const Color(0xB40000FF); + const Color highlightColor = const Color(0xAAFF0000); + const Color splashColor = const Color(0xB40000FF); final BorderRadius borderRadius = new BorderRadius.circular(6.0); await tester.pumpWidget( @@ -111,7 +111,7 @@ void main() { final double radius = arguments[1]; final Paint paint = arguments[2]; final Offset expectedCenter = tapDownOffset + const Offset(17.0, 17.0); - final double expectedRadius = 56.0; + const double expectedRadius = 56.0; if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius) && paint.color.alpha == 120) return true; throw ''' @@ -129,7 +129,7 @@ void main() { final double radius = arguments[1]; final Paint paint = arguments[2]; final Offset expectedCenter = tapDownOffset + const Offset(29.0, 29.0); - final double expectedRadius = 73.0; + const double expectedRadius = 73.0; if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius) && paint.color.alpha == 180) return true; throw ''' @@ -149,7 +149,7 @@ void main() { final double radius = arguments[1]; final Paint paint = arguments[2]; final Offset expectedCenter = inkWellCenter; - final double expectedRadius = 105.0; + const double expectedRadius = 105.0; if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius) && paint.color.alpha == 180) return true; throw ''' @@ -166,7 +166,7 @@ void main() { final double radius = arguments[1]; final Paint paint = arguments[2]; final Offset expectedCenter = inkWellCenter; - final double expectedRadius = 105.0; + const double expectedRadius = 105.0; if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius) && paint.color.alpha == 0) return true; throw ''' diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 3a5e423867..74eaff8637 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -1034,7 +1034,7 @@ void main() { }); testWidgets('InputDecorator.toString()', (WidgetTester tester) async { - final Widget child = const InputDecorator( + const Widget child = const InputDecorator( key: const Key('key'), decoration: const InputDecoration(), baseStyle: const TextStyle(), diff --git a/packages/flutter/test/material/localizations_test.dart b/packages/flutter/test/material/localizations_test.dart index e68e79ca0c..9b09bb845c 100644 --- a/packages/flutter/test/material/localizations_test.dart +++ b/packages/flutter/test/material/localizations_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('English translations exist for all MaterialLocalizations properties', (WidgetTester tester) async { - final MaterialLocalizations localizations = const DefaultMaterialLocalizations(); + const MaterialLocalizations localizations = const DefaultMaterialLocalizations(); expect(localizations.openAppDrawerTooltip, isNotNull); expect(localizations.backButtonTooltip, isNotNull); diff --git a/packages/flutter/test/material/mergeable_material_test.dart b/packages/flutter/test/material/mergeable_material_test.dart index 1ceb9cd8b5..5449008fd6 100644 --- a/packages/flutter/test/material/mergeable_material_test.dart +++ b/packages/flutter/test/material/mergeable_material_test.dart @@ -1044,7 +1044,7 @@ void main() { bool isDivider(Widget widget, bool top, bool bottom) { final DecoratedBox box = widget; - final BorderSide side = const BorderSide(color: const Color(0x1F000000), width: 0.5); + const BorderSide side = const BorderSide(color: const Color(0x1F000000), width: 0.5); return box.decoration == new BoxDecoration( border: new Border( diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index 16506acaa6..6d2fb5bf55 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -188,7 +188,7 @@ void main() { testWidgets('Slider has a customizable active color', (WidgetTester tester) async { - final Color customColor = const Color(0xFF4CD964); + const Color customColor = const Color(0xFF4CD964); final ThemeData theme = new ThemeData(platform: TargetPlatform.android); Widget buildApp(Color activeColor) { return new Directionality( @@ -226,7 +226,7 @@ void main() { testWidgets('Slider has a customizable inactive color', (WidgetTester tester) async { - final Color customColor = const Color(0xFF4CD964); + const Color customColor = const Color(0xFF4CD964); final ThemeData theme = new ThemeData(platform: TargetPlatform.android); Widget buildApp(Color inactiveColor) { return new Directionality( diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index a05542d48b..a8529c0851 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -7,16 +7,16 @@ import 'package:flutter/material.dart'; void main() { testWidgets('SnackBar control test', (WidgetTester tester) async { - final String helloSnackBar = 'Hello SnackBar'; - final Key tapTarget = const Key('tap-target'); + const String helloSnackBar = 'Hello SnackBar'; + const Key tapTarget = const Key('tap-target'); await tester.pumpWidget(new MaterialApp( home: new Scaffold( body: new Builder( builder: (BuildContext context) { return new GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( - content: new Text(helloSnackBar), + Scaffold.of(context).showSnackBar(const SnackBar( + content: const Text(helloSnackBar), duration: const Duration(seconds: 2) )); }, @@ -53,7 +53,7 @@ void main() { testWidgets('SnackBar twice test', (WidgetTester tester) async { int snackBarCount = 0; - final Key tapTarget = const Key('tap-target'); + const 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; - final Key tapTarget = const Key('tap-target'); + const 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; - final Key tapTarget = const Key('tap-target'); + const 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 ed7cc6bc68..06de02a670 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -231,7 +231,7 @@ void main() { testWidgets('Scrollable TabBar tap centers selected tab', (WidgetTester tester) async { final List tabs = ['AAAAAA', 'BBBBBB', 'CCCCCC', 'DDDDDD', 'EEEEEE', 'FFFFFF', 'GGGGGG', 'HHHHHH', 'IIIIII', 'JJJJJJ', 'KKKKKK', 'LLLLLL']; - final Key tabBarKey = const Key('TabBar'); + const Key tabBarKey = const Key('TabBar'); await tester.pumpWidget(buildFrame(tabs: tabs, value: 'AAAAAA', isScrollable: true, tabBarKey: tabBarKey)); final TabController controller = DefaultTabController.of(tester.element(find.text('AAAAAA'))); expect(controller, isNotNull); @@ -251,7 +251,7 @@ void main() { testWidgets('TabBar can be scrolled independent of the selection', (WidgetTester tester) async { final List tabs = ['AAAA', 'BBBB', 'CCCC', 'DDDD', 'EEEE', 'FFFF', 'GGGG', 'HHHH', 'IIII', 'JJJJ', 'KKKK', 'LLLL']; - final Key tabBarKey = const Key('TabBar'); + const Key tabBarKey = const Key('TabBar'); await tester.pumpWidget(buildFrame(tabs: tabs, value: 'AAAA', isScrollable: true, tabBarKey: tabBarKey)); final TabController controller = DefaultTabController.of(tester.element(find.text('AAAA'))); expect(controller, isNotNull); diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 3b1103c26f..745564dbd6 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -303,7 +303,7 @@ void main() { expect(controller.selection.baseOffset, -1); expect(controller.selection.extentOffset, -1); - final String testValue = 'abc def ghi'; + const String testValue = 'abc def ghi'; await tester.enterText(find.byType(TextField), testValue); await skipPastScrollingAnimation(tester); @@ -328,7 +328,7 @@ void main() { ) ); - final String testValue = 'abc def ghi'; + const String testValue = 'abc def ghi'; await tester.enterText(find.byType(TextField), testValue); expect(controller.value.text, testValue); await skipPastScrollingAnimation(tester); @@ -358,7 +358,7 @@ void main() { ), ); - final String testValue = 'abc def ghi'; + const String testValue = 'abc def ghi'; await tester.enterText(find.byType(TextField), testValue); await skipPastScrollingAnimation(tester); @@ -419,7 +419,7 @@ void main() { ), ); - final String testValue = 'abc def ghi'; + const String testValue = 'abc def ghi'; await tester.enterText(find.byType(TextField), testValue); await skipPastScrollingAnimation(tester); @@ -477,7 +477,7 @@ void main() { ), ); - final String testValue = 'abc def ghi'; + const String testValue = 'abc def ghi'; await tester.enterText(find.byType(TextField), testValue); await skipPastScrollingAnimation(tester); @@ -587,7 +587,7 @@ void main() { ); final String testValue = kThreeLines; - final String cutValue = 'First line of stuff '; + const String cutValue = 'First line of stuff '; await tester.enterText(find.byType(TextField), testValue); await skipPastScrollingAnimation(tester); @@ -1603,11 +1603,11 @@ void main() { testWidgets('maxLength shows warning when maxLengthEnforced is false.', (WidgetTester tester) async { final TextEditingController textController = new TextEditingController(); - final TextStyle testStyle = const TextStyle(color: Colors.deepPurpleAccent); + const TextStyle testStyle = const TextStyle(color: Colors.deepPurpleAccent); await tester.pumpWidget(boilerplate( child: new TextField( - decoration: new InputDecoration(errorStyle: testStyle), + decoration: const InputDecoration(errorStyle: testStyle), controller: textController, maxLength: 10, maxLengthEnforced: false, @@ -1686,7 +1686,7 @@ void main() { ) ); - final String testValue = 'x'; + const String testValue = 'x'; await tester.enterText(find.byType(TextField), testValue); await skipPastScrollingAnimation(tester); expect(controller.selection.baseOffset, -1); 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 0a29e42761..1bf1c75dfd 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -199,9 +199,9 @@ void main() { )); expect(find.text('A'), findsOneWidget); - final Key avatarA = const Key('A'); + const Key avatarA = const Key('A'); await tester.pumpWidget(buildFrame( - currentAccountPicture: new CircleAvatar(key: avatarA, child: const Text('A')), + currentAccountPicture: const CircleAvatar(key: avatarA, child: const Text('A')), accountName: const Text('accountName'), )); expect( @@ -310,9 +310,9 @@ void main() { )); expect(find.text('A'), findsOneWidget); - final Key avatarA = const Key('A'); + const Key avatarA = const Key('A'); await tester.pumpWidget(buildFrame( - currentAccountPicture: new CircleAvatar(key: avatarA, child: const Text('A')), + currentAccountPicture: const CircleAvatar(key: avatarA, child: const Text('A')), accountName: const Text('accountName'), )); expect( diff --git a/packages/flutter/test/painting/alignment_test.dart b/packages/flutter/test/painting/alignment_test.dart index b4a0f18f5f..31d03d461a 100644 --- a/packages/flutter/test/painting/alignment_test.dart +++ b/packages/flutter/test/painting/alignment_test.dart @@ -179,8 +179,8 @@ void main() { }); test('AlignmentGeometry add/subtract', () { - final AlignmentGeometry directional = const AlignmentDirectional(1.0, 2.0); - final AlignmentGeometry normal = const Alignment(3.0, 5.0); + const AlignmentGeometry directional = const AlignmentDirectional(1.0, 2.0); + const AlignmentGeometry normal = const Alignment(3.0, 5.0); expect(directional.add(normal).resolve(TextDirection.ltr), const Alignment(4.0, 7.0)); expect(directional.add(normal).resolve(TextDirection.rtl), const Alignment(2.0, 7.0)); expect(normal.add(normal), normal * 2.0); diff --git a/packages/flutter/test/painting/border_radius_test.dart b/packages/flutter/test/painting/border_radius_test.dart index ac45a11b39..b49bebd64a 100644 --- a/packages/flutter/test/painting/border_radius_test.dart +++ b/packages/flutter/test/painting/border_radius_test.dart @@ -142,17 +142,17 @@ void main() { }); test('BorderRadius.lerp() crazy', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0), topRight: const Radius.elliptical(30.0, 40.0), bottomLeft: const Radius.elliptical(50.0, 60.0), ); - final BorderRadius b = const BorderRadius.only( + const BorderRadius b = const BorderRadius.only( topRight: const Radius.elliptical(100.0, 110.0), bottomLeft: const Radius.elliptical(120.0, 130.0), bottomRight: const Radius.elliptical(140.0, 150.0), ); - final BorderRadius c = const BorderRadius.only( + const BorderRadius c = const BorderRadius.only( topLeft: const Radius.elliptical(5.0, 10.0), // 10,20 -> 0 topRight: const Radius.elliptical(65.0, 75.0), // 30,40 -> 100,110 bottomLeft: const Radius.elliptical(85.0, 95.0), // 50,60 -> 120,130 @@ -321,17 +321,17 @@ void main() { }); test('BorderRadiusDirectional.lerp() crazy', () { - final BorderRadiusDirectional a = const BorderRadiusDirectional.only( + const BorderRadiusDirectional a = const BorderRadiusDirectional.only( topStart: const Radius.elliptical(10.0, 20.0), topEnd: const Radius.elliptical(30.0, 40.0), bottomStart: const Radius.elliptical(50.0, 60.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topEnd: const Radius.elliptical(100.0, 110.0), bottomStart: const Radius.elliptical(120.0, 130.0), bottomEnd: const Radius.elliptical(140.0, 150.0), ); - final BorderRadiusDirectional c = const BorderRadiusDirectional.only( + const BorderRadiusDirectional c = const BorderRadiusDirectional.only( topStart: const Radius.elliptical(5.0, 10.0), // 10,20 -> 0 topEnd: const Radius.elliptical(65.0, 75.0), // 30,40 -> 100,110 bottomStart: const Radius.elliptical(85.0, 95.0), // 50,60 -> 120,130 @@ -341,23 +341,23 @@ void main() { }); test('BorderRadiusGeometry.lerp()', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0), topRight: const Radius.elliptical(30.0, 40.0), bottomLeft: const Radius.elliptical(50.0, 60.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topEnd: const Radius.elliptical(100.0, 110.0), bottomStart: const Radius.elliptical(120.0, 130.0), bottomEnd: const Radius.elliptical(140.0, 150.0), ); - final BorderRadius ltr = const BorderRadius.only( + const BorderRadius ltr = const BorderRadius.only( topLeft: const Radius.elliptical(5.0, 10.0), // 10,20 -> 0 topRight: const Radius.elliptical(65.0, 75.0), // 30,40 -> 100,110 bottomLeft: const Radius.elliptical(85.0, 95.0), // 50,60 -> 120,130 bottomRight: const Radius.elliptical(70.0, 75.0), // 0,0 -> 140,150 ); - final BorderRadius rtl = const BorderRadius.only( + const BorderRadius rtl = const BorderRadius.only( topLeft: const Radius.elliptical(55.0, 65.0), // 10,20 -> 100,110 topRight: const Radius.elliptical(15.0, 20.0), // 30,40 -> 0,0 bottomLeft: const Radius.elliptical(95.0, 105.0), // 50,60 -> 140,150 @@ -370,12 +370,12 @@ void main() { }); test('BorderRadiusGeometry subtract', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0), topRight: const Radius.elliptical(30.0, 40.0), bottomLeft: const Radius.elliptical(50.0, 60.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topEnd: const Radius.elliptical(100.0, 110.0), bottomStart: const Radius.elliptical(120.0, 130.0), bottomEnd: const Radius.elliptical(140.0, 150.0), @@ -395,12 +395,12 @@ void main() { }); test('BorderRadiusGeometry add', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0), topRight: const Radius.elliptical(30.0, 40.0), bottomLeft: const Radius.elliptical(50.0, 60.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topEnd: const Radius.elliptical(100.0, 110.0), bottomStart: const Radius.elliptical(120.0, 130.0), bottomEnd: const Radius.elliptical(140.0, 150.0), @@ -420,12 +420,12 @@ void main() { }); test('BorderRadiusGeometry add and multiply', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0), topRight: const Radius.elliptical(30.0, 40.0), bottomLeft: const Radius.elliptical(50.0, 60.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topEnd: const Radius.elliptical(100.0, 110.0), bottomStart: const Radius.elliptical(120.0, 130.0), bottomEnd: const Radius.elliptical(140.0, 150.0), @@ -445,23 +445,23 @@ void main() { }); test('BorderRadiusGeometry add and subtract', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(300.0, 500.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topEnd: const Radius.elliptical(30.0, 50.0), ); - final BorderRadius c = const BorderRadius.only( + const BorderRadius c = const BorderRadius.only( bottomLeft: const Radius.elliptical(3.0, 5.0), ); - final BorderRadius ltr = const BorderRadius.only( + const BorderRadius ltr = const BorderRadius.only( topLeft: const Radius.elliptical(300.0, 500.0), // tL + 0 - 0 topRight: const Radius.elliptical(30.0, 50.0), // 0 + tE - 0 bottomLeft: const Radius.elliptical(-3.0, -5.0), // 0 + 0 - bL bottomRight: Radius.zero, // 0 + 0 - 0 ); - final BorderRadius rtl = const BorderRadius.only( + const BorderRadius rtl = const BorderRadius.only( topLeft: const Radius.elliptical(330.0, 550.0), // tL + tE - 0 topRight: Radius.zero, // 0 + 0 - 0 bottomLeft: const Radius.elliptical(-3.0, -5.0), // 0 + 0 - bL @@ -472,32 +472,32 @@ void main() { }); test('BorderRadiusGeometry add and subtract, more', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(300.0, 300.0), topRight: const Radius.elliptical(500.0, 500.0), bottomLeft: const Radius.elliptical(700.0, 700.0), bottomRight: const Radius.elliptical(900.0, 900.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topStart: const Radius.elliptical(30.0, 30.0), topEnd: const Radius.elliptical(50.0, 50.0), bottomStart: const Radius.elliptical(70.0, 70.0), bottomEnd: const Radius.elliptical(90.0, 90.0), ); - final BorderRadius c = const BorderRadius.only( + const BorderRadius c = const BorderRadius.only( topLeft: const Radius.elliptical(3.0, 3.0), topRight: const Radius.elliptical(5.0, 5.0), bottomLeft: const Radius.elliptical(7.0, 7.0), bottomRight: const Radius.elliptical(9.0, 9.0), ); - final BorderRadius ltr = const BorderRadius.only( + const BorderRadius ltr = const BorderRadius.only( topLeft: const Radius.elliptical(327.0, 327.0), // tL + tS - tL topRight: const Radius.elliptical(545.0, 545.0), // tR + tE - tR bottomLeft: const Radius.elliptical(763.0, 763.0), // bL + bS - bL bottomRight: const Radius.elliptical(981.0, 981.0), // bR + bE - bR ); - final BorderRadius rtl = const BorderRadius.only( + const BorderRadius rtl = const BorderRadius.only( topLeft: const Radius.elliptical(347.0, 347.0), // tL + tE - tL topRight: const Radius.elliptical(525.0, 525.0), // tR + TS - tR bottomLeft: const Radius.elliptical(783.0, 783.0), // bL + bE + bL @@ -508,24 +508,24 @@ void main() { }); test('BorderRadiusGeometry operators', () { - final BorderRadius a = const BorderRadius.only( + const BorderRadius a = const BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0), topRight: const Radius.elliptical(30.0, 40.0), bottomLeft: const Radius.elliptical(50.0, 60.0), ); - final BorderRadiusDirectional b = const BorderRadiusDirectional.only( + const BorderRadiusDirectional b = const BorderRadiusDirectional.only( topEnd: const Radius.elliptical(100.0, 110.0), bottomStart: const Radius.elliptical(120.0, 130.0), bottomEnd: const Radius.elliptical(140.0, 150.0), ); - final BorderRadius ltr = const BorderRadius.only( + const BorderRadius ltr = const BorderRadius.only( topLeft: const Radius.elliptical(5.0, 10.0), // 10,20 -> 0 topRight: const Radius.elliptical(65.0, 75.0), // 30,40 -> 100,110 bottomLeft: const Radius.elliptical(85.0, 95.0), // 50,60 -> 120,130 bottomRight: const Radius.elliptical(70.0, 75.0), // 0,0 -> 140,150 ); - final BorderRadius rtl = const BorderRadius.only( + const BorderRadius rtl = const BorderRadius.only( topLeft: const Radius.elliptical(55.0, 65.0), // 10,20 -> 100,110 topRight: const Radius.elliptical(15.0, 20.0), // 30,40 -> 0,0 bottomLeft: const Radius.elliptical(95.0, 105.0), // 50,60 -> 140,150 diff --git a/packages/flutter/test/painting/border_rtl_test.dart b/packages/flutter/test/painting/border_rtl_test.dart index d29b6508b0..300d3faee2 100644 --- a/packages/flutter/test/painting/border_rtl_test.dart +++ b/packages/flutter/test/painting/border_rtl_test.dart @@ -15,32 +15,32 @@ class SillyBorder extends BoxBorder { void main() { test('BoxBorder.lerp', () { // names of the form fooAtX are foo, lerped X% of the way to null - final BoxBorder directionalWithMagentaTop5 = const BorderDirectional(top: const BorderSide(color: const Color(0xFFFF00FF), width: 5.0)); - final BoxBorder directionalWithMagentaTop5At25 = const BorderDirectional(top: const BorderSide(color: const Color(0x3F3F003F), width: 1.25)); - final BoxBorder directionalWithMagentaTop5At75 = const BorderDirectional(top: const BorderSide(color: const Color(0xBFBF00BF), width: 3.75)); - final BoxBorder directionalWithSides10 = const BorderDirectional(start: const BorderSide(width: 10.0), end: const BorderSide(width: 20.0)); - final BoxBorder directionalWithSides10At25 = const BorderDirectional(start: const BorderSide(width: 2.5, color: const Color(0x3F000000)), end: const BorderSide(width: 5.0, color: const Color(0x3F000000))); - final BoxBorder directionalWithSides10At50 = const BorderDirectional(start: const BorderSide(width: 5.0, color: const Color(0x7F000000)), end: const BorderSide(width: 10.0, color: const Color(0x7F000000))); - final BoxBorder directionalWithSides10At75 = const BorderDirectional(start: const BorderSide(width: 7.5, color: const Color(0xBF000000)), end: const BorderSide(width: 15.0, color: const Color(0xBF000000))); - final BoxBorder directionalWithSides20 = const BorderDirectional(start: const BorderSide(width: 20.0), end: const BorderSide(width: 40.0)); - final BoxBorder directionalWithSides30 = const BorderDirectional(start: const BorderSide(width: 30.0), end: const BorderSide(width: 60.0)); - final BoxBorder directionalWithTop10 = const BorderDirectional(top: const BorderSide(width: 10.0)); - final BoxBorder directionalWithYellowTop10 = const BorderDirectional(top: const BorderSide(color: const Color(0xFFFFFF00), width: 10.0)); - final BoxBorder directionalWithYellowTop5 = const BorderDirectional(top: const BorderSide(color: const Color(0xFFFFFF00), width: 5.0)); - final BoxBorder visualWithMagentaTop10 = const Border(top: const BorderSide(color: const Color(0xFFFF00FF), width: 10.0)); - final BoxBorder visualWithMagentaTop5 = const Border(top: const BorderSide(color: const Color(0xFFFF00FF), width: 5.0)); - final BoxBorder visualWithSides10 = const Border(left: const BorderSide(width: 10.0), right: const BorderSide(width: 20.0)); - final BoxBorder visualWithSides10At25 = const Border(left: const BorderSide(width: 2.5, color: const Color(0x3F000000)), right: const BorderSide(width: 5.0, color: const Color(0x3F000000))); - final BoxBorder visualWithSides10At50 = const Border(left: const BorderSide(width: 5.0, color: const Color(0x7F000000)), right: const BorderSide(width: 10.0, color: const Color(0x7F000000))); - final BoxBorder visualWithSides10At75 = const Border(left: const BorderSide(width: 7.5, color: const Color(0xBF000000)), right: const BorderSide(width: 15.0, color: const Color(0xBF000000))); - final BoxBorder visualWithSides20 = const Border(left: const BorderSide(width: 20.0), right: const BorderSide(width: 40.0)); - final BoxBorder visualWithSides30 = const Border(left: const BorderSide(width: 30.0), right: const BorderSide(width: 60.0)); - final BoxBorder visualWithTop10 = const Border(top: const BorderSide(width: 10.0)); - final BoxBorder visualWithTop100 = const Border(top: const BorderSide(width: 100.0)); - final BoxBorder visualWithTop190 = const Border(top: const BorderSide(width: 190.0)); - final BoxBorder visualWithYellowTop5 = const Border(top: const BorderSide(color: const Color(0xFFFFFF00), width: 5.0)); - final BoxBorder visualWithYellowTop5At25 = const Border(top: const BorderSide(color: const Color(0x3F3F3F00), width: 1.25)); - final BoxBorder visualWithYellowTop5At75 = const Border(top: const BorderSide(color: const Color(0xBFBFBF00), width: 3.75)); + const BoxBorder directionalWithMagentaTop5 = const BorderDirectional(top: const BorderSide(color: const Color(0xFFFF00FF), width: 5.0)); + const BoxBorder directionalWithMagentaTop5At25 = const BorderDirectional(top: const BorderSide(color: const Color(0x3F3F003F), width: 1.25)); + const BoxBorder directionalWithMagentaTop5At75 = const BorderDirectional(top: const BorderSide(color: const Color(0xBFBF00BF), width: 3.75)); + const BoxBorder directionalWithSides10 = const BorderDirectional(start: const BorderSide(width: 10.0), end: const BorderSide(width: 20.0)); + const BoxBorder directionalWithSides10At25 = const BorderDirectional(start: const BorderSide(width: 2.5, color: const Color(0x3F000000)), end: const BorderSide(width: 5.0, color: const Color(0x3F000000))); + const BoxBorder directionalWithSides10At50 = const BorderDirectional(start: const BorderSide(width: 5.0, color: const Color(0x7F000000)), end: const BorderSide(width: 10.0, color: const Color(0x7F000000))); + const BoxBorder directionalWithSides10At75 = const BorderDirectional(start: const BorderSide(width: 7.5, color: const Color(0xBF000000)), end: const BorderSide(width: 15.0, color: const Color(0xBF000000))); + const BoxBorder directionalWithSides20 = const BorderDirectional(start: const BorderSide(width: 20.0), end: const BorderSide(width: 40.0)); + const BoxBorder directionalWithSides30 = const BorderDirectional(start: const BorderSide(width: 30.0), end: const BorderSide(width: 60.0)); + const BoxBorder directionalWithTop10 = const BorderDirectional(top: const BorderSide(width: 10.0)); + const BoxBorder directionalWithYellowTop10 = const BorderDirectional(top: const BorderSide(color: const Color(0xFFFFFF00), width: 10.0)); + const BoxBorder directionalWithYellowTop5 = const BorderDirectional(top: const BorderSide(color: const Color(0xFFFFFF00), width: 5.0)); + const BoxBorder visualWithMagentaTop10 = const Border(top: const BorderSide(color: const Color(0xFFFF00FF), width: 10.0)); + const BoxBorder visualWithMagentaTop5 = const Border(top: const BorderSide(color: const Color(0xFFFF00FF), width: 5.0)); + const BoxBorder visualWithSides10 = const Border(left: const BorderSide(width: 10.0), right: const BorderSide(width: 20.0)); + const BoxBorder visualWithSides10At25 = const Border(left: const BorderSide(width: 2.5, color: const Color(0x3F000000)), right: const BorderSide(width: 5.0, color: const Color(0x3F000000))); + const BoxBorder visualWithSides10At50 = const Border(left: const BorderSide(width: 5.0, color: const Color(0x7F000000)), right: const BorderSide(width: 10.0, color: const Color(0x7F000000))); + const BoxBorder visualWithSides10At75 = const Border(left: const BorderSide(width: 7.5, color: const Color(0xBF000000)), right: const BorderSide(width: 15.0, color: const Color(0xBF000000))); + const BoxBorder visualWithSides20 = const Border(left: const BorderSide(width: 20.0), right: const BorderSide(width: 40.0)); + const BoxBorder visualWithSides30 = const Border(left: const BorderSide(width: 30.0), right: const BorderSide(width: 60.0)); + const BoxBorder visualWithTop10 = const Border(top: const BorderSide(width: 10.0)); + const BoxBorder visualWithTop100 = const Border(top: const BorderSide(width: 100.0)); + const BoxBorder visualWithTop190 = const Border(top: const BorderSide(width: 190.0)); + const BoxBorder visualWithYellowTop5 = const Border(top: const BorderSide(color: const Color(0xFFFFFF00), width: 5.0)); + const BoxBorder visualWithYellowTop5At25 = const Border(top: const BorderSide(color: const Color(0x3F3F3F00), width: 1.25)); + const BoxBorder visualWithYellowTop5At75 = const Border(top: const BorderSide(color: const Color(0xBFBFBF00), width: 3.75)); expect(BoxBorder.lerp(null, null, -1.0), null); expect(BoxBorder.lerp(new Border.all(width: 10.0), null, -1.0), new Border.all(width: 20.0)); @@ -117,8 +117,8 @@ void main() { test('BoxBorder.getInnerPath / BoxBorder.getOuterPath', () { // for Border, BorderDirectional - final Border border = const Border(top: const BorderSide(width: 10.0), right: const BorderSide(width: 20.0)); - final BorderDirectional borderDirectional = const BorderDirectional(top: const BorderSide(width: 10.0), end: const BorderSide(width: 20.0)); + const Border border = const Border(top: const BorderSide(width: 10.0), right: const BorderSide(width: 20.0)); + const BorderDirectional borderDirectional = const BorderDirectional(top: const BorderSide(width: 10.0), end: const BorderSide(width: 20.0)); expect( border.getOuterPath(new Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), isPathThat( @@ -325,30 +325,30 @@ void main() { }); test('BorderDirectional.merge', () { - final BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); - final BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); - final BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); - final BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); + const BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); + const BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); + const BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); + const BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); expect( BorderDirectional.merge( - new BorderDirectional(top: yellow2), - new BorderDirectional(end: magenta3), + const BorderDirectional(top: yellow2), + const BorderDirectional(end: magenta3), ), - new BorderDirectional(top: yellow2, end: magenta3), + const BorderDirectional(top: yellow2, end: magenta3), ); expect( BorderDirectional.merge( - new BorderDirectional(bottom: magenta3), - new BorderDirectional(bottom: magenta3), + const BorderDirectional(bottom: magenta3), + const BorderDirectional(bottom: magenta3), ), - new BorderDirectional(bottom: magenta6), + const BorderDirectional(bottom: magenta6), ); expect( BorderDirectional.merge( - new BorderDirectional(start: magenta3, end: yellowNone0), - new BorderDirectional(end: yellow2), + const BorderDirectional(start: magenta3, end: yellowNone0), + const BorderDirectional(end: yellow2), ), - new BorderDirectional(start: magenta3, end: yellow2), + const BorderDirectional(start: magenta3, end: yellow2), ); expect( BorderDirectional.merge(const BorderDirectional(), const BorderDirectional()), @@ -356,8 +356,8 @@ void main() { ); expect( () => BorderDirectional.merge( - new BorderDirectional(start: magenta3), - new BorderDirectional(start: yellow2), + const BorderDirectional(start: magenta3), + const BorderDirectional(start: yellow2), ), throwsAssertionError, ); @@ -446,35 +446,35 @@ void main() { }); test('BorderDirectional.add - all directional', () { - final BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); - final BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); - final BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); - final BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); + const BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); + const BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); + const BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); + const BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); expect( - new BorderDirectional(top: yellow2) + new BorderDirectional(end: magenta3), - new BorderDirectional(top: yellow2, end: magenta3), + const BorderDirectional(top: yellow2) + const BorderDirectional(end: magenta3), + const BorderDirectional(top: yellow2, end: magenta3), ); expect( - new BorderDirectional(bottom: magenta3) + new BorderDirectional(bottom: magenta3), - new BorderDirectional(bottom: magenta6), + const BorderDirectional(bottom: magenta3) + const BorderDirectional(bottom: magenta3), + const BorderDirectional(bottom: magenta6), ); expect( - new BorderDirectional(start: magenta3, end: yellowNone0) + new BorderDirectional(end: yellow2), - new BorderDirectional(start: magenta3, end: yellow2), + const BorderDirectional(start: magenta3, end: yellowNone0) + const BorderDirectional(end: yellow2), + const BorderDirectional(start: magenta3, end: yellow2), ); expect( const BorderDirectional() + const BorderDirectional(), const BorderDirectional(), ); expect( - new BorderDirectional(start: magenta3) + new BorderDirectional(start: yellow2), + const BorderDirectional(start: magenta3) + const BorderDirectional(start: yellow2), isNot(const isInstanceOf()), // see shape_border_test.dart for better tests of this case ); - final BorderDirectional b3 = new BorderDirectional(top: magenta3); - final BorderDirectional b6 = new BorderDirectional(top: magenta6); + const BorderDirectional b3 = const BorderDirectional(top: magenta3); + const BorderDirectional b6 = const BorderDirectional(top: magenta6); expect(b3 + b3, b6); - final BorderDirectional b0 = new BorderDirectional(top: yellowNone0); - final BorderDirectional bZ = const BorderDirectional(); + const BorderDirectional b0 = const BorderDirectional(top: yellowNone0); + const BorderDirectional bZ = const BorderDirectional(); expect(b0 + b0, bZ); expect(bZ + bZ, bZ); expect(b0 + bZ, bZ); @@ -534,27 +534,27 @@ void main() { }); test('BorderDirectional.scale', () { - final BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); - final BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); - final BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); - final BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); - final BorderDirectional b3 = new BorderDirectional(start: magenta3); - final BorderDirectional b6 = new BorderDirectional(start: magenta6); + const BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); + const BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); + const BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); + const BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); + const BorderDirectional b3 = const BorderDirectional(start: magenta3); + const BorderDirectional b6 = const BorderDirectional(start: magenta6); expect(b3.scale(2.0), b6); - final BorderDirectional bY0 = new BorderDirectional(top: yellowNone0); + const BorderDirectional bY0 = const BorderDirectional(top: yellowNone0); expect(bY0.scale(3.0), bY0); - final BorderDirectional bY2 = new BorderDirectional(top: yellow2); + const BorderDirectional bY2 = const BorderDirectional(top: yellow2); expect(bY2.scale(0.0), bY0); }); test('BorderDirectional.lerp', () { - final BorderDirectional directionalWithTop10 = const BorderDirectional(top: const BorderSide(width: 10.0)); - final BorderDirectional atMinus100 = const BorderDirectional(start: const BorderSide(width: 0.0), end: const BorderSide(width: 300.0)); - final BorderDirectional at0 = const BorderDirectional(start: const BorderSide(width: 100.0), end: const BorderSide(width: 200.0)); - final BorderDirectional at25 = const BorderDirectional(start: const BorderSide(width: 125.0), end: const BorderSide(width: 175.0)); - final BorderDirectional at75 = const BorderDirectional(start: const BorderSide(width: 175.0), end: const BorderSide(width: 125.0)); - final BorderDirectional at100 = const BorderDirectional(start: const BorderSide(width: 200.0), end: const BorderSide(width: 100.0)); - final BorderDirectional at200 = const BorderDirectional(start: const BorderSide(width: 300.0), end: const BorderSide(width: 0.0)); + const BorderDirectional directionalWithTop10 = const BorderDirectional(top: const BorderSide(width: 10.0)); + const BorderDirectional atMinus100 = const BorderDirectional(start: const BorderSide(width: 0.0), end: const BorderSide(width: 300.0)); + const BorderDirectional at0 = const BorderDirectional(start: const BorderSide(width: 100.0), end: const BorderSide(width: 200.0)); + const BorderDirectional at25 = const BorderDirectional(start: const BorderSide(width: 125.0), end: const BorderSide(width: 175.0)); + const BorderDirectional at75 = const BorderDirectional(start: const BorderSide(width: 175.0), end: const BorderSide(width: 125.0)); + const BorderDirectional at100 = const BorderDirectional(start: const BorderSide(width: 200.0), end: const BorderSide(width: 100.0)); + const BorderDirectional at200 = const BorderDirectional(start: const BorderSide(width: 300.0), end: const BorderSide(width: 0.0)); expect(BorderDirectional.lerp(null, null, -1.0), null); expect(BorderDirectional.lerp(directionalWithTop10, null, -1.0), const BorderDirectional(top: const BorderSide(width: 20.0))); diff --git a/packages/flutter/test/painting/border_side_test.dart b/packages/flutter/test/painting/border_side_test.dart index 44cf9ccf22..d5b403f952 100644 --- a/packages/flutter/test/painting/border_side_test.dart +++ b/packages/flutter/test/painting/border_side_test.dart @@ -32,20 +32,20 @@ void main() { ); }); test('BorderSide - merging', () { - final BorderSide blue = const BorderSide(color: const Color(0xFF0000FF)); - final BorderSide blue2 = const BorderSide(color: const Color(0xFF0000FF), width: 2.0); - final BorderSide green = const BorderSide(color: const Color(0xFF00FF00)); - final BorderSide green2 = const BorderSide(color: const Color(0xFF00FF00), width: 2.0); - final BorderSide green3 = const BorderSide(color: const Color(0xFF00FF00), width: 3.0); - final BorderSide green5 = const BorderSide(color: const Color(0xFF00FF00), width: 5.0); - final BorderSide none = const BorderSide(style: BorderStyle.none); - final BorderSide none2 = const BorderSide(color: const Color(0xFF0000FF), width: 2.0, style: BorderStyle.none); - final BorderSide none3 = const BorderSide(style: BorderStyle.none, width: 3.0); - final BorderSide side2 = const BorderSide(width: 2.0); - final BorderSide side3 = const BorderSide(width: 3.0); - final BorderSide side5 = const BorderSide(width: 5.0); - final BorderSide solid = const BorderSide(style: BorderStyle.solid); - final BorderSide yellowNone = const BorderSide(style: BorderStyle.none, color: const Color(0xFFFFFF00), width: 0.0); + const BorderSide blue = const BorderSide(color: const Color(0xFF0000FF)); + const BorderSide blue2 = const BorderSide(color: const Color(0xFF0000FF), width: 2.0); + const BorderSide green = const BorderSide(color: const Color(0xFF00FF00)); + const BorderSide green2 = const BorderSide(color: const Color(0xFF00FF00), width: 2.0); + const BorderSide green3 = const BorderSide(color: const Color(0xFF00FF00), width: 3.0); + const BorderSide green5 = const BorderSide(color: const Color(0xFF00FF00), width: 5.0); + const BorderSide none = const BorderSide(style: BorderStyle.none); + const BorderSide none2 = const BorderSide(color: const Color(0xFF0000FF), width: 2.0, style: BorderStyle.none); + const BorderSide none3 = const BorderSide(style: BorderStyle.none, width: 3.0); + const BorderSide side2 = const BorderSide(width: 2.0); + const BorderSide side3 = const BorderSide(width: 3.0); + const BorderSide side5 = const BorderSide(width: 5.0); + const BorderSide solid = const BorderSide(style: BorderStyle.solid); + const BorderSide yellowNone = const BorderSide(style: BorderStyle.none, color: const Color(0xFFFFFF00), width: 0.0); // canMerge expect( BorderSide.canMerge(BorderSide.none, BorderSide.none), isTrue); expect( BorderSide.canMerge(BorderSide.none, side2), isTrue); @@ -92,20 +92,20 @@ void main() { expect( BorderSide.merge(yellowNone, yellowNone), BorderSide.none); }); test('BorderSide - asserts when copied incorrectly', () { - final BorderSide green2 = const BorderSide(color: const Color(0xFF00FF00), width: 2.0); - final BorderSide blue3 = const BorderSide(color: const Color(0xFF0000FF), width: 3.0); - final BorderSide blue2 = const BorderSide(color: const Color(0xFF0000FF), width: 2.0); - final BorderSide green3 = const BorderSide(color: const Color(0xFF00FF00), width: 3.0); - final BorderSide none2 = const BorderSide(color: const Color(0xFF00FF00), width: 2.0, style: BorderStyle.none); + const BorderSide green2 = const BorderSide(color: const Color(0xFF00FF00), width: 2.0); + const BorderSide blue3 = const BorderSide(color: const Color(0xFF0000FF), width: 3.0); + const BorderSide blue2 = const BorderSide(color: const Color(0xFF0000FF), width: 2.0); + const BorderSide green3 = const BorderSide(color: const Color(0xFF00FF00), width: 3.0); + const BorderSide none2 = const BorderSide(color: const Color(0xFF00FF00), width: 2.0, style: BorderStyle.none); expect(green2.copyWith(color: const Color(0xFF0000FF), width: 3.0), blue3); expect(green2.copyWith(width: 3.0), green3); expect(green2.copyWith(color: const Color(0xFF0000FF)), blue2); expect(green2.copyWith(style: BorderStyle.none), none2); }); test('BorderSide - scale', () { - final BorderSide side3 = const BorderSide(width: 3.0, color: const Color(0xFF0000FF)); - final BorderSide side6 = const BorderSide(width: 6.0, color: const Color(0xFF0000FF)); - final BorderSide none = const BorderSide(style: BorderStyle.none, width: 0.0, color: const Color(0xFF0000FF)); + const BorderSide side3 = const BorderSide(width: 3.0, color: const Color(0xFF0000FF)); + const BorderSide side6 = const BorderSide(width: 6.0, color: const Color(0xFF0000FF)); + const BorderSide none = const BorderSide(style: BorderStyle.none, width: 0.0, color: const Color(0xFF0000FF)); expect(side3.scale(2.0), side6); expect(side6.scale(0.5), side3); expect(side6.scale(0.0), none); @@ -125,9 +125,9 @@ void main() { expect(paint2.blendMode, BlendMode.srcOver); }); test('BorderSide - won\'t lerp into negative widths', () { - final BorderSide side0 = const BorderSide(width: 0.0); - final BorderSide side1 = const BorderSide(width: 1.0); - final BorderSide side2 = const BorderSide(width: 2.0); + const BorderSide side0 = const BorderSide(width: 0.0); + const BorderSide side1 = const BorderSide(width: 1.0); + const BorderSide side2 = const BorderSide(width: 2.0); expect(BorderSide.lerp(side2, side1, 10.0), BorderSide.none); expect(BorderSide.lerp(side1, side2, -10.0), BorderSide.none); expect(BorderSide.lerp(side0, side1, 2.0), side2); diff --git a/packages/flutter/test/painting/border_test.dart b/packages/flutter/test/painting/border_test.dart index 3d8f95c473..bd28a44f7f 100644 --- a/packages/flutter/test/painting/border_test.dart +++ b/packages/flutter/test/painting/border_test.dart @@ -15,30 +15,30 @@ void main() { }); test('Border.merge', () { - final BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); - final BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); - final BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); - final BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); + const BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); + const BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); + const BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); + const BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); expect( Border.merge( - new Border(top: yellow2), - new Border(right: magenta3), + const Border(top: yellow2), + const Border(right: magenta3), ), - new Border(top: yellow2, right: magenta3), + const Border(top: yellow2, right: magenta3), ); expect( Border.merge( - new Border(bottom: magenta3), - new Border(bottom: magenta3), + const Border(bottom: magenta3), + const Border(bottom: magenta3), ), - new Border(bottom: magenta6), + const Border(bottom: magenta6), ); expect( Border.merge( - new Border(left: magenta3, right: yellowNone0), - new Border(right: yellow2), + const Border(left: magenta3, right: yellowNone0), + const Border(right: yellow2), ), - new Border(left: magenta3, right: yellow2), + const Border(left: magenta3, right: yellow2), ); expect( Border.merge(const Border(), const Border()), @@ -46,43 +46,43 @@ void main() { ); expect( () => Border.merge( - new Border(left: magenta3), - new Border(left: yellow2), + const Border(left: magenta3), + const Border(left: yellow2), ), throwsAssertionError, ); }); test('Border.add', () { - final BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); - final BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); - final BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); - final BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); + const BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); + const BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); + const BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); + const BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); expect( - new Border(top: yellow2) + new Border(right: magenta3), - new Border(top: yellow2, right: magenta3), + const Border(top: yellow2) + const Border(right: magenta3), + const Border(top: yellow2, right: magenta3), ); expect( - new Border(bottom: magenta3) + new Border(bottom: magenta3), - new Border(bottom: magenta6), + const Border(bottom: magenta3) + const Border(bottom: magenta3), + const Border(bottom: magenta6), ); expect( - new Border(left: magenta3, right: yellowNone0) + new Border(right: yellow2), - new Border(left: magenta3, right: yellow2), + const Border(left: magenta3, right: yellowNone0) + const Border(right: yellow2), + const Border(left: magenta3, right: yellow2), ); expect( const Border() + const Border(), const Border(), ); expect( - new Border(left: magenta3) + new Border(left: yellow2), + const Border(left: magenta3) + const Border(left: yellow2), isNot(const isInstanceOf()), // see shape_border_test.dart for better tests of this case ); - final Border b3 = new Border(top: magenta3); - final Border b6 = new Border(top: magenta6); + const Border b3 = const Border(top: magenta3); + const Border b6 = const Border(top: magenta6); expect(b3 + b3, b6); - final Border b0 = new Border(top: yellowNone0); - final Border bZ = const Border(); + const Border b0 = const Border(top: yellowNone0); + const Border bZ = const Border(); expect(b0 + b0, bZ); expect(bZ + bZ, bZ); expect(b0 + bZ, bZ); @@ -90,16 +90,16 @@ void main() { }); test('Border.scale', () { - final BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); - final BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); - final BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); - final BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); - final Border b3 = new Border(left: magenta3); - final Border b6 = new Border(left: magenta6); + const BorderSide magenta3 = const BorderSide(color: const Color(0xFFFF00FF), width: 3.0); + const BorderSide magenta6 = const BorderSide(color: const Color(0xFFFF00FF), width: 6.0); + const BorderSide yellow2 = const BorderSide(color: const Color(0xFFFFFF00), width: 2.0); + const BorderSide yellowNone0 = const BorderSide(color: const Color(0xFFFFFF00), width: 0.0, style: BorderStyle.none); + const Border b3 = const Border(left: magenta3); + const Border b6 = const Border(left: magenta6); expect(b3.scale(2.0), b6); - final Border bY0 = new Border(top: yellowNone0); + const Border bY0 = const Border(top: yellowNone0); expect(bY0.scale(3.0), bY0); - final Border bY2 = new Border(top: yellow2); + const Border bY2 = const Border(top: yellow2); expect(bY2.scale(0.0), bY0); }); @@ -195,13 +195,13 @@ void main() { }); test('Border.lerp', () { - final Border visualWithTop10 = const Border(top: const BorderSide(width: 10.0)); - final Border atMinus100 = const Border(left: const BorderSide(width: 0.0), right: const BorderSide(width: 300.0)); - final Border at0 = const Border(left: const BorderSide(width: 100.0), right: const BorderSide(width: 200.0)); - final Border at25 = const Border(left: const BorderSide(width: 125.0), right: const BorderSide(width: 175.0)); - final Border at75 = const Border(left: const BorderSide(width: 175.0), right: const BorderSide(width: 125.0)); - final Border at100 = const Border(left: const BorderSide(width: 200.0), right: const BorderSide(width: 100.0)); - final Border at200 = const Border(left: const BorderSide(width: 300.0), right: const BorderSide(width: 0.0)); + const Border visualWithTop10 = const Border(top: const BorderSide(width: 10.0)); + const Border atMinus100 = const Border(left: const BorderSide(width: 0.0), right: const BorderSide(width: 300.0)); + const Border at0 = const Border(left: const BorderSide(width: 100.0), right: const BorderSide(width: 200.0)); + const Border at25 = const Border(left: const BorderSide(width: 125.0), right: const BorderSide(width: 175.0)); + const Border at75 = const Border(left: const BorderSide(width: 175.0), right: const BorderSide(width: 125.0)); + const Border at100 = const Border(left: const BorderSide(width: 200.0), right: const BorderSide(width: 100.0)); + const Border at200 = const Border(left: const BorderSide(width: 300.0), right: const BorderSide(width: 0.0)); expect(Border.lerp(null, null, -1.0), null); expect(Border.lerp(visualWithTop10, null, -1.0), const Border(top: const BorderSide(width: 20.0))); diff --git a/packages/flutter/test/painting/box_decoration_test.dart b/packages/flutter/test/painting/box_decoration_test.dart index f3e273ce91..4d051ca4ea 100644 --- a/packages/flutter/test/painting/box_decoration_test.dart +++ b/packages/flutter/test/painting/box_decoration_test.dart @@ -9,7 +9,7 @@ import '../rendering/mock_canvas.dart'; void main() { test('BoxDecoration with BorderRadiusDirectional', () { - final BoxDecoration decoration = const BoxDecoration( + const BoxDecoration decoration = const BoxDecoration( color: const Color(0xFF000000), borderRadius: const BorderRadiusDirectional.only(topStart: const Radius.circular(100.0)), ); diff --git a/packages/flutter/test/painting/box_painter_test.dart b/packages/flutter/test/painting/box_painter_test.dart index 364b76840d..947feb1ee2 100644 --- a/packages/flutter/test/painting/box_painter_test.dart +++ b/packages/flutter/test/painting/box_painter_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/painting.dart'; void main() { test('BorderSide control test', () { - final BorderSide side1 = const BorderSide(); + const BorderSide side1 = const BorderSide(); final BorderSide side2 = side1.copyWith( color: const Color(0xFF00FFFF), width: 2.0, @@ -40,7 +40,7 @@ void main() { }); test('BorderSide toString test', () { - final BorderSide side1 = const BorderSide(); + const BorderSide side1 = const BorderSide(); final BorderSide side2 = side1.copyWith( color: const Color(0xFF00FFFF), width: 2.0, @@ -87,7 +87,7 @@ void main() { }); test('BoxShadow control test', () { - final BoxShadow shadow1 = const BoxShadow(blurRadius: 4.0); + const BoxShadow shadow1 = const BoxShadow(blurRadius: 4.0); final BoxShadow shadow2 = BoxShadow.lerp(null, shadow1, 0.25); final BoxShadow shadow3 = BoxShadow.lerp(shadow1, null, 0.25); diff --git a/packages/flutter/test/painting/circle_border_test.dart b/packages/flutter/test/painting/circle_border_test.dart index 8f302e0c18..29c3078939 100644 --- a/packages/flutter/test/painting/circle_border_test.dart +++ b/packages/flutter/test/painting/circle_border_test.dart @@ -10,9 +10,9 @@ import 'common_matchers.dart'; void main() { test('CircleBorder', () { - final CircleBorder c10 = const CircleBorder(side: const BorderSide(width: 10.0)); - final CircleBorder c15 = const CircleBorder(side: const BorderSide(width: 15.0)); - final CircleBorder c20 = const CircleBorder(side: const BorderSide(width: 20.0)); + const CircleBorder c10 = const CircleBorder(side: const BorderSide(width: 10.0)); + const CircleBorder c15 = const CircleBorder(side: const BorderSide(width: 15.0)); + const CircleBorder c20 = const CircleBorder(side: const BorderSide(width: 20.0)); expect(c10.dimensions, const EdgeInsets.all(10.0)); expect(c10.scale(2.0), c20); expect(c20.scale(0.5), c10); diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart index c4d2314efa..438f250191 100644 --- a/packages/flutter/test/painting/decoration_test.dart +++ b/packages/flutter/test/painting/decoration_test.dart @@ -93,8 +93,8 @@ void main() { new TestRenderingFlutterBinding(); // initializes the imageCache test('Decoration.lerp()', () { - final BoxDecoration a = const BoxDecoration(color: const Color(0xFFFFFFFF)); - final BoxDecoration b = const BoxDecoration(color: const Color(0x00000000)); + const BoxDecoration a = const BoxDecoration(color: const Color(0xFFFFFFFF)); + const BoxDecoration b = const BoxDecoration(color: const Color(0x00000000)); BoxDecoration c = Decoration.lerp(a, b, 0.0); expect(c.color, equals(a.color)); @@ -117,7 +117,7 @@ void main() { }); final TestCanvas canvas = new TestCanvas(); - final ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero); + const ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero); boxPainter.paint(canvas, Offset.zero, imageConfiguration); // The onChanged callback should not be invoked during the call to boxPainter.paint @@ -136,7 +136,7 @@ void main() { }); final TestCanvas canvas = new TestCanvas(); - final ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero); + const ImageConfiguration imageConfiguration = const ImageConfiguration(size: Size.zero); boxPainter.paint(canvas, Offset.zero, imageConfiguration); // The onChanged callback should be invoked asynchronously. @@ -163,7 +163,7 @@ void main() { final List invocations = []; final TestCanvas canvas = new TestCanvas(invocations); - final ImageConfiguration imageConfiguration = const ImageConfiguration( + const ImageConfiguration imageConfiguration = const ImageConfiguration( size: const Size(100.0, 100.0) ); bool onChangedCalled = false; @@ -203,7 +203,7 @@ void main() { }); test('DecorationImage test', () { - final ColorFilter colorFilter = const ui.ColorFilter.mode(const Color(0xFF00FF00), BlendMode.src); + const ColorFilter colorFilter = const ui.ColorFilter.mode(const Color(0xFF00FF00), BlendMode.src); final DecorationImage backgroundImage = new DecorationImage( image: new SynchronousTestImageProvider(), colorFilter: colorFilter, @@ -284,11 +284,11 @@ void main() { }); test('BoxDecoration.lerp - gradients', () { - final Gradient gradient = const LinearGradient(colors: const [ const Color(0x00000000), const Color(0xFFFFFFFF) ]); + const Gradient gradient = const LinearGradient(colors: const [ const Color(0x00000000), const Color(0xFFFFFFFF) ]); expect( BoxDecoration.lerp( const BoxDecoration(), - new BoxDecoration(gradient: gradient), + const BoxDecoration(gradient: gradient), -1.0, ), const BoxDecoration(gradient: const LinearGradient(colors: const [ const Color(0x00000000), const Color(0x00FFFFFF) ])) @@ -296,7 +296,7 @@ void main() { expect( BoxDecoration.lerp( const BoxDecoration(), - new BoxDecoration(gradient: gradient), + const BoxDecoration(gradient: gradient), 0.0, ), const BoxDecoration() @@ -304,7 +304,7 @@ void main() { expect( BoxDecoration.lerp( const BoxDecoration(), - new BoxDecoration(gradient: gradient), + const BoxDecoration(gradient: gradient), 0.25, ), const BoxDecoration(gradient: const LinearGradient(colors: const [ const Color(0x00000000), const Color(0x40FFFFFF) ])) @@ -312,7 +312,7 @@ void main() { expect( BoxDecoration.lerp( const BoxDecoration(), - new BoxDecoration(gradient: gradient), + const BoxDecoration(gradient: gradient), 0.75, ), const BoxDecoration(gradient: const LinearGradient(colors: const [ const Color(0x00000000), const Color(0xBFFFFFFF) ])) @@ -320,18 +320,18 @@ void main() { expect( BoxDecoration.lerp( const BoxDecoration(), - new BoxDecoration(gradient: gradient), + const BoxDecoration(gradient: gradient), 1.0, ), - new BoxDecoration(gradient: gradient) + const BoxDecoration(gradient: gradient) ); expect( BoxDecoration.lerp( const BoxDecoration(), - new BoxDecoration(gradient: gradient), + const BoxDecoration(gradient: gradient), 2.0, ), - new BoxDecoration(gradient: gradient) + const BoxDecoration(gradient: gradient) ); }); diff --git a/packages/flutter/test/painting/edge_insets_test.dart b/packages/flutter/test/painting/edge_insets_test.dart index 5239074c5f..813d617a3b 100644 --- a/packages/flutter/test/painting/edge_insets_test.dart +++ b/packages/flutter/test/painting/edge_insets_test.dart @@ -39,8 +39,8 @@ void main() { }); test('EdgeInsets.lerp()', () { - final EdgeInsets a = const EdgeInsets.all(10.0); - final EdgeInsets b = const EdgeInsets.all(20.0); + const EdgeInsets a = const EdgeInsets.all(10.0); + const EdgeInsets b = const EdgeInsets.all(20.0); expect(EdgeInsets.lerp(a, b, 0.25), equals(a * 1.25)); expect(EdgeInsets.lerp(a, b, 0.25), equals(b * 0.625)); expect(EdgeInsets.lerp(a, b, 0.25), equals(a + const EdgeInsets.all(2.5))); @@ -95,7 +95,7 @@ void main() { }); test('EdgeInsets copyWith', () { - final EdgeInsets sourceEdgeInsets = const EdgeInsets.only(left: 1.0, top: 2.0, bottom: 3.0, right: 4.0); + const EdgeInsets sourceEdgeInsets = const EdgeInsets.only(left: 1.0, top: 2.0, bottom: 3.0, right: 4.0); final EdgeInsets copy = sourceEdgeInsets.copyWith(left: 5.0, top: 6.0); expect(copy, const EdgeInsets.only(left: 5.0, top: 6.0, bottom: 3.0, right: 4.0)); }); @@ -113,8 +113,8 @@ void main() { }); test('EdgeInsetsGeometry.lerp(normal, ...)', () { - final EdgeInsets a = const EdgeInsets.all(10.0); - final EdgeInsets b = const EdgeInsets.all(20.0); + const EdgeInsets a = const EdgeInsets.all(10.0); + const EdgeInsets b = const EdgeInsets.all(20.0); expect(EdgeInsetsGeometry.lerp(a, b, 0.25), equals(a * 1.25)); expect(EdgeInsetsGeometry.lerp(a, b, 0.25), equals(b * 0.625)); expect(EdgeInsetsGeometry.lerp(a, b, 0.25), equals(a + const EdgeInsets.all(2.5))); @@ -126,8 +126,8 @@ void main() { }); test('EdgeInsetsGeometry.lerp(directional, ...)', () { - final EdgeInsetsDirectional a = const EdgeInsetsDirectional.only(start: 10.0, end: 10.0); - final EdgeInsetsDirectional b = const EdgeInsetsDirectional.only(start: 20.0, end: 20.0); + const EdgeInsetsDirectional a = const EdgeInsetsDirectional.only(start: 10.0, end: 10.0); + const EdgeInsetsDirectional b = const EdgeInsetsDirectional.only(start: 20.0, end: 20.0); expect(EdgeInsetsGeometry.lerp(a, b, 0.25), equals(a * 1.25)); expect(EdgeInsetsGeometry.lerp(a, b, 0.25), equals(b * 0.625)); expect(EdgeInsetsGeometry.lerp(a, b, 0.25), equals(a + const EdgeInsetsDirectional.only(start: 2.5, end: 2.5))); diff --git a/packages/flutter/test/painting/gradient_test.dart b/packages/flutter/test/painting/gradient_test.dart index 8b54ef352c..b35c974447 100644 --- a/packages/flutter/test/painting/gradient_test.dart +++ b/packages/flutter/test/painting/gradient_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/painting.dart'; void main() { test('LinearGradient scale test', () { - final LinearGradient testGradient = const LinearGradient( + const LinearGradient testGradient = const LinearGradient( begin: Alignment.bottomRight, end: const Alignment(0.7, 1.0), colors: const [ @@ -30,7 +30,7 @@ void main() { }); test('LinearGradient lerp test', () { - final LinearGradient testGradient1 = const LinearGradient( + const LinearGradient testGradient1 = const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomLeft, colors: const [ @@ -38,7 +38,7 @@ void main() { const Color(0x66666666), ], ); - final LinearGradient testGradient2 = const LinearGradient( + const LinearGradient testGradient2 = const LinearGradient( begin: Alignment.topRight, end: Alignment.topLeft, colors: const [ @@ -153,7 +153,7 @@ void main() { }); test('RadialGradient lerp test', () { - final RadialGradient testGradient1 = const RadialGradient( + const RadialGradient testGradient1 = const RadialGradient( center: Alignment.topLeft, radius: 20.0, colors: const [ @@ -161,7 +161,7 @@ void main() { const Color(0x66666666), ], ); - final RadialGradient testGradient2 = const RadialGradient( + const RadialGradient testGradient2 = const RadialGradient( center: Alignment.topRight, radius: 10.0, colors: const [ @@ -182,7 +182,7 @@ void main() { }); test('Gradient lerp test (with RadialGradient)', () { - final RadialGradient testGradient1 = const RadialGradient( + const RadialGradient testGradient1 = const RadialGradient( center: Alignment.topLeft, radius: 20.0, colors: const [ @@ -190,7 +190,7 @@ void main() { const Color(0x66666666), ], ); - final RadialGradient testGradient2 = const RadialGradient( + const RadialGradient testGradient2 = const RadialGradient( center: const Alignment(0.0, -1.0), radius: 15.0, colors: const [ @@ -198,7 +198,7 @@ void main() { const Color(0x77777777), ], ); - final RadialGradient testGradient3 = const RadialGradient( + const RadialGradient testGradient3 = const RadialGradient( center: Alignment.topRight, radius: 10.0, colors: const [ @@ -216,7 +216,7 @@ void main() { }); test('Gradient lerp test (LinearGradient to RadialGradient)', () { - final LinearGradient testGradient1 = const LinearGradient( + const LinearGradient testGradient1 = const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: const [ @@ -224,7 +224,7 @@ void main() { const Color(0x66666666), ], ); - final RadialGradient testGradient2 = const RadialGradient( + const RadialGradient testGradient2 = const RadialGradient( center: Alignment.center, radius: 20.0, colors: const [ @@ -239,21 +239,21 @@ void main() { }); test('Gradients can handle missing stops and report mismatched stops', () { - final LinearGradient test1a = const LinearGradient( + const LinearGradient test1a = const LinearGradient( colors: const [ const Color(0x11111111), const Color(0x22222222), const Color(0x33333333), ], ); - final RadialGradient test1b = const RadialGradient( + const RadialGradient test1b = const RadialGradient( colors: const [ const Color(0x11111111), const Color(0x22222222), const Color(0x33333333), ], ); - final LinearGradient test2a = const LinearGradient( + const LinearGradient test2a = const LinearGradient( colors: const [ const Color(0x11111111), const Color(0x22222222), @@ -261,7 +261,7 @@ void main() { ], stops: const [0.0, 1.0], ); - final RadialGradient test2b = const RadialGradient( + const RadialGradient test2b = const RadialGradient( colors: const [ const Color(0x11111111), const Color(0x22222222), diff --git a/packages/flutter/test/painting/rounded_rectangle_border_test.dart b/packages/flutter/test/painting/rounded_rectangle_border_test.dart index 76d0a9cdac..a874f424bd 100644 --- a/packages/flutter/test/painting/rounded_rectangle_border_test.dart +++ b/packages/flutter/test/painting/rounded_rectangle_border_test.dart @@ -38,7 +38,7 @@ void main() { test('RoundedRectangleBorder and CircleBorder', () { final RoundedRectangleBorder r = new RoundedRectangleBorder(side: BorderSide.none, borderRadius: new BorderRadius.circular(10.0)); - final CircleBorder c = const CircleBorder(side: BorderSide.none); + const CircleBorder c = const CircleBorder(side: BorderSide.none); final Rect rect = new Rect.fromLTWH(0.0, 0.0, 100.0, 20.0); // center is x=40..60 y=10 final Matcher looksLikeR = isPathThat( includes: const [ const Offset(30.0, 10.0), const Offset(50.0, 10.0), ], diff --git a/packages/flutter/test/painting/shape_border_test.dart b/packages/flutter/test/painting/shape_border_test.dart index 1e05595974..d268a6e607 100644 --- a/packages/flutter/test/painting/shape_border_test.dart +++ b/packages/flutter/test/painting/shape_border_test.dart @@ -72,10 +72,10 @@ void main() { }); test('Compound borders', () { - final BorderSide side1 = const BorderSide(color: const Color(0xFF00FF00)); - final BorderSide side2 = const BorderSide(color: const Color(0xFF0000FF)); - final BorderDirectional b1 = new BorderDirectional(top: side1, start: side1, end: side1, bottom: side1); - final BorderDirectional b2 = new BorderDirectional(top: side2, start: side2, end: side2, bottom: side2); + const BorderSide side1 = const BorderSide(color: const Color(0xFF00FF00)); + const BorderSide side2 = const BorderSide(color: const Color(0xFF0000FF)); + const BorderDirectional b1 = const BorderDirectional(top: side1, start: side1, end: side1, bottom: side1); + const BorderDirectional b2 = const BorderDirectional(top: side2, start: side2, end: side2, bottom: side2); expect( (b1 + b2).toString(), 'BorderDirectional(top: BorderSide(Color(0xff00ff00), 1.0, BorderStyle.solid), start: BorderSide(Color(0xff00ff00), 1.0, BorderStyle.solid), end: BorderSide(Color(0xff00ff00), 1.0, BorderStyle.solid), bottom: BorderSide(Color(0xff00ff00), 1.0, BorderStyle.solid)) + ' diff --git a/packages/flutter/test/painting/shape_decoration_test.dart b/packages/flutter/test/painting/shape_decoration_test.dart index bcc8ae5933..2a5d5ab519 100644 --- a/packages/flutter/test/painting/shape_decoration_test.dart +++ b/packages/flutter/test/painting/shape_decoration_test.dart @@ -15,12 +15,12 @@ void main() { new TestRenderingFlutterBinding(); // initializes the imageCache test('ShapeDecoration constructor', () { - final Color colorR = const Color(0xffff0000); - final Color colorG = const Color(0xff00ff00); + const Color colorR = const Color(0xffff0000); + const Color colorG = const Color(0xff00ff00); final Gradient gradient = new LinearGradient(colors: [colorR, colorG]); expect(const ShapeDecoration(shape: const Border()), const ShapeDecoration(shape: const Border())); expect(() => new ShapeDecoration(color: colorR, gradient: gradient, shape: const Border()), throwsAssertionError); - expect(() => new ShapeDecoration(color: colorR, shape: null), throwsAssertionError); + expect(() => new ShapeDecoration(gradient: gradient, shape: null), throwsAssertionError); expect( new ShapeDecoration.fromBoxDecoration(const BoxDecoration(shape: BoxShape.circle)), const ShapeDecoration(shape: const CircleBorder(side: BorderSide.none)), @@ -31,7 +31,7 @@ void main() { ); expect( new ShapeDecoration.fromBoxDecoration(new BoxDecoration(shape: BoxShape.circle, border: new Border.all(color: colorG))), - new ShapeDecoration(shape: new CircleBorder(side: new BorderSide(color: colorG))), + const ShapeDecoration(shape: const CircleBorder(side: const BorderSide(color: colorG))), ); expect( new ShapeDecoration.fromBoxDecoration(new BoxDecoration(shape: BoxShape.rectangle, border: new Border.all(color: colorR))), @@ -44,8 +44,8 @@ void main() { }); test('ShapeDecoration.lerp and hit test', () { - final Decoration a = const ShapeDecoration(shape: const CircleBorder()); - final Decoration b = const ShapeDecoration(shape: const RoundedRectangleBorder()); + const Decoration a = const ShapeDecoration(shape: const CircleBorder()); + const Decoration b = const ShapeDecoration(shape: const RoundedRectangleBorder()); expect(Decoration.lerp(a, b, 0.0), a); expect(Decoration.lerp(a, b, 1.0), b); const Size size = const Size(200.0, 100.0); // at t=0.5, width will be 150 (x=25 to x=175). diff --git a/packages/flutter/test/painting/stadium_border_test.dart b/packages/flutter/test/painting/stadium_border_test.dart index a4613c8da2..a491c10ca8 100644 --- a/packages/flutter/test/painting/stadium_border_test.dart +++ b/packages/flutter/test/painting/stadium_border_test.dart @@ -10,9 +10,9 @@ import 'common_matchers.dart'; void main() { test('StadiumBorder', () { - final StadiumBorder c10 = const StadiumBorder(side: const BorderSide(width: 10.0)); - final StadiumBorder c15 = const StadiumBorder(side: const BorderSide(width: 15.0)); - final StadiumBorder c20 = const StadiumBorder(side: const BorderSide(width: 20.0)); + const StadiumBorder c10 = const StadiumBorder(side: const BorderSide(width: 10.0)); + const StadiumBorder c15 = const StadiumBorder(side: const BorderSide(width: 15.0)); + const StadiumBorder c20 = const StadiumBorder(side: const BorderSide(width: 20.0)); expect(c10.dimensions, const EdgeInsets.all(10.0)); expect(c10.scale(2.0), c20); expect(c20.scale(0.5), c10); @@ -20,9 +20,9 @@ void main() { expect(ShapeBorder.lerp(c10, c20, 0.5), c15); expect(ShapeBorder.lerp(c10, c20, 1.0), c20); - final StadiumBorder c1 = const StadiumBorder(side: const BorderSide(width: 1.0)); + const StadiumBorder c1 = const StadiumBorder(side: const BorderSide(width: 1.0)); expect(c1.getOuterPath(new Rect.fromCircle(center: Offset.zero, radius: 1.0)), isUnitCircle); - final StadiumBorder c2 = const StadiumBorder(side: const BorderSide(width: 1.0)); + const StadiumBorder c2 = const StadiumBorder(side: const BorderSide(width: 1.0)); expect(c2.getInnerPath(new Rect.fromCircle(center: Offset.zero, radius: 2.0)), isUnitCircle); final Rect rect = new Rect.fromLTRB(10.0, 20.0, 100.0, 200.0); expect( @@ -36,8 +36,8 @@ void main() { }); test('StadiumBorder and CircleBorder', () { - final StadiumBorder stadium = const StadiumBorder(side: BorderSide.none); - final CircleBorder circle = const CircleBorder(side: BorderSide.none); + const StadiumBorder stadium = const StadiumBorder(side: BorderSide.none); + const CircleBorder circle = const CircleBorder(side: BorderSide.none); final Rect rect = new Rect.fromLTWH(0.0, 0.0, 100.0, 20.0); final Matcher looksLikeS = isPathThat( includes: const [ const Offset(30.0, 10.0), const Offset(50.0, 10.0), ], @@ -87,8 +87,8 @@ void main() { }); test('StadiumBorder and RoundedRectBorder', () { - final StadiumBorder stadium = const StadiumBorder(side: BorderSide.none); - final RoundedRectangleBorder rrect = const RoundedRectangleBorder(side: BorderSide.none); + const StadiumBorder stadium = const StadiumBorder(side: BorderSide.none); + const RoundedRectangleBorder rrect = const RoundedRectangleBorder(side: BorderSide.none); final Rect rect = new Rect.fromLTWH(0.0, 0.0, 100.0, 50.0); final Matcher looksLikeS = isPathThat( includes: const [ diff --git a/packages/flutter/test/painting/text_span_test.dart b/packages/flutter/test/painting/text_span_test.dart index 001219238a..75ec26e57f 100644 --- a/packages/flutter/test/painting/text_span_test.dart +++ b/packages/flutter/test/painting/text_span_test.dart @@ -13,7 +13,7 @@ void main() { final TextSpan a2 = new TextSpan(text: text); final TextSpan b1 = new TextSpan(children: [ a1 ]); final TextSpan b2 = new TextSpan(children: [ a2 ]); - String nullText; // we want these instances to be separate instances so that we're not just checking with a single object + final String nullText = null; // we want these instances to be separate instances so that we're not just checking with a single object final TextSpan c1 = new TextSpan(text: nullText); final TextSpan c2 = new TextSpan(text: nullText); @@ -31,7 +31,7 @@ void main() { }); test('TextSpan toStringDeep', () { - final TextSpan test = const TextSpan( + const TextSpan test = const TextSpan( text: 'a', style: const TextStyle( fontSize: 10.0, diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart index f6c1ff9d5e..98a9781f0d 100644 --- a/packages/flutter/test/painting/text_style_test.dart +++ b/packages/flutter/test/painting/text_style_test.dart @@ -18,7 +18,7 @@ void main() { equals('TextStyle()'), ); - final TextStyle s1 = const TextStyle( + const TextStyle s1 = const TextStyle( fontSize: 10.0, fontWeight: FontWeight.w800, height: 123.0, @@ -134,11 +134,11 @@ void main() { }); test('TextStyle using package font', () { - final TextStyle s6 = const TextStyle(fontFamily: 'test'); + const TextStyle s6 = const TextStyle(fontFamily: 'test'); expect(s6.fontFamily, 'test'); expect(s6.getTextStyle().toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: test, fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified)'); - final TextStyle s7 = const TextStyle(fontFamily: 'test', package: 'p'); + const TextStyle s7 = const TextStyle(fontFamily: 'test', package: 'p'); expect(s7.fontFamily, 'packages/p/test'); expect(s7.getTextStyle().toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: packages/p/test, fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified)'); }); diff --git a/packages/flutter/test/physics/newton_test.dart b/packages/flutter/test/physics/newton_test.dart index 724353c663..4eed86deda 100644 --- a/packages/flutter/test/physics/newton_test.dart +++ b/packages/flutter/test/physics/newton_test.dart @@ -48,7 +48,7 @@ void main() { expect(friction.x(0.0), 10.0); expect(friction.dx(0.0), 600.0); - final double epsilon = 1e-4; + const double epsilon = 1e-4; expect(friction.isDone(1.0 + epsilon), true); expect(friction.x(1.0), closeTo(endPosition, epsilon)); expect(friction.dx(1.0), closeTo(endVelocity, epsilon)); diff --git a/packages/flutter/test/rendering/box_constraints_test.dart b/packages/flutter/test/rendering/box_constraints_test.dart index a65cef8f89..aaa807320b 100644 --- a/packages/flutter/test/rendering/box_constraints_test.dart +++ b/packages/flutter/test/rendering/box_constraints_test.dart @@ -13,7 +13,7 @@ void main() { }); test('BoxConstraints copyWith', () { - final BoxConstraints constraints = const BoxConstraints( + const BoxConstraints constraints = const BoxConstraints( minWidth: 3.0, maxWidth: 7.0, minHeight: 11.0, @@ -36,7 +36,7 @@ void main() { }); test('BoxConstraints operators', () { - final BoxConstraints constraints = const BoxConstraints( + const BoxConstraints constraints = const BoxConstraints( minWidth: 3.0, maxWidth: 7.0, minHeight: 11.0, @@ -62,7 +62,7 @@ void main() { test('BoxConstraints lerp', () { expect(BoxConstraints.lerp(null, null, 0.5), isNull); - final BoxConstraints constraints = const BoxConstraints( + const BoxConstraints constraints = const BoxConstraints( minWidth: 3.0, maxWidth: 7.0, minHeight: 11.0, @@ -91,19 +91,19 @@ void main() { }); test('BoxConstraints lerp with unbounded width', () { - final BoxConstraints constraints1 = const BoxConstraints( + const BoxConstraints constraints1 = const BoxConstraints( minWidth: double.INFINITY, maxWidth: double.INFINITY, minHeight: 10.0, maxHeight: 20.0, ); - final BoxConstraints constraints2 = const BoxConstraints( + const BoxConstraints constraints2 = const BoxConstraints( minWidth: double.INFINITY, maxWidth: double.INFINITY, minHeight: 20.0, maxHeight: 30.0, ); - final BoxConstraints constraints3 = const BoxConstraints( + const BoxConstraints constraints3 = const BoxConstraints( minWidth: double.INFINITY, maxWidth: double.INFINITY, minHeight: 15.0, @@ -113,19 +113,19 @@ void main() { }); test('BoxConstraints lerp with unbounded height', () { - final BoxConstraints constraints1 = const BoxConstraints( + const BoxConstraints constraints1 = const BoxConstraints( minWidth: 10.0, maxWidth: 20.0, minHeight: double.INFINITY, maxHeight: double.INFINITY, ); - final BoxConstraints constraints2 = const BoxConstraints( + const BoxConstraints constraints2 = const BoxConstraints( minWidth: 20.0, maxWidth: 30.0, minHeight: double.INFINITY, maxHeight: double.INFINITY, ); - final BoxConstraints constraints3 = const BoxConstraints( + const BoxConstraints constraints3 = const BoxConstraints( minWidth: 15.0, maxWidth: 25.0, minHeight: double.INFINITY, @@ -135,19 +135,19 @@ void main() { }); test('BoxConstraints lerp from bounded to unbounded', () { - final BoxConstraints constraints1 = const BoxConstraints( + const BoxConstraints constraints1 = const BoxConstraints( minWidth: double.INFINITY, maxWidth: double.INFINITY, minHeight: double.INFINITY, maxHeight: double.INFINITY, ); - final BoxConstraints constraints2 = const BoxConstraints( + const BoxConstraints constraints2 = const BoxConstraints( minWidth: 20.0, maxWidth: 30.0, minHeight: double.INFINITY, maxHeight: double.INFINITY, ); - final BoxConstraints constraints3 = const BoxConstraints( + const BoxConstraints constraints3 = const BoxConstraints( minWidth: double.INFINITY, maxWidth: double.INFINITY, minHeight: 20.0, @@ -159,7 +159,7 @@ void main() { }); test('BoxConstraints normalize', () { - final BoxConstraints constraints = const BoxConstraints( + const BoxConstraints constraints = const BoxConstraints( minWidth: 3.0, maxWidth: 2.0, minHeight: 11.0, diff --git a/packages/flutter/test/rendering/box_test.dart b/packages/flutter/test/rendering/box_test.dart index d8a7b324ae..2a2a6bc4e0 100644 --- a/packages/flutter/test/rendering/box_test.dart +++ b/packages/flutter/test/rendering/box_test.dart @@ -163,7 +163,7 @@ void main() { ), alignment: Alignment.center, ); - final BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); + const BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); layout(unconstrained, constraints: viewport); expect(unconstrained.getMinIntrinsicHeight(100.0), equals(200.0)); expect(unconstrained.getMaxIntrinsicHeight(100.0), equals(200.0)); @@ -179,7 +179,7 @@ void main() { ), alignment: Alignment.center, ); - final BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); + const BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); layout(unconstrained, constraints: viewport); expect(unconstrained.getMinIntrinsicHeight(100.0), equals(0.0)); expect(unconstrained.getMaxIntrinsicHeight(100.0), equals(0.0)); @@ -224,7 +224,7 @@ void main() { flexParentData.flex = 1; flexParentData.fit = FlexFit.tight; - final BoxConstraints viewport = const BoxConstraints(maxWidth: 100.0); + const BoxConstraints viewport = const BoxConstraints(maxWidth: 100.0); layout(unconstrained, constraints: viewport); expect(unconstrained.size.width, equals(100.0), reason: 'constrained width'); @@ -248,7 +248,7 @@ void main() { flexParentData.flex = 1; flexParentData.fit = FlexFit.tight; - final BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0); + const BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0); layout(unconstrained, constraints: viewport); expect(unconstrained.size.width, equals(200.0), reason: 'unconstrained width'); diff --git a/packages/flutter/test/rendering/constraints_test.dart b/packages/flutter/test/rendering/constraints_test.dart index a373dfda0a..f355125178 100644 --- a/packages/flutter/test/rendering/constraints_test.dart +++ b/packages/flutter/test/rendering/constraints_test.dart @@ -36,7 +36,7 @@ void main() { result = 'no exception'; try { - final BoxConstraints constraints = const BoxConstraints(minWidth: double.NAN, maxWidth: double.NAN, minHeight: 2.0, maxHeight: double.NAN); + const BoxConstraints constraints = const BoxConstraints(minWidth: double.NAN, maxWidth: double.NAN, minHeight: 2.0, maxHeight: double.NAN); assert(constraints.debugAssertIsValid()); } on FlutterError catch (e) { result = '$e'; @@ -49,7 +49,7 @@ void main() { result = 'no exception'; try { - final BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN); + const BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN); assert(constraints.debugAssertIsValid()); } on FlutterError catch (e) { result = '$e'; @@ -62,7 +62,7 @@ void main() { result = 'no exception'; try { - final BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN, maxWidth: 0.0/0.0); + const BoxConstraints constraints = const BoxConstraints(minHeight: double.NAN, maxWidth: 0.0/0.0); assert(constraints.debugAssertIsValid()); } on FlutterError catch (e) { result = '$e'; diff --git a/packages/flutter/test/rendering/debug_overflow_indicator_test.dart b/packages/flutter/test/rendering/debug_overflow_indicator_test.dart index e092ea090e..f25ed1ad30 100644 --- a/packages/flutter/test/rendering/debug_overflow_indicator_test.dart +++ b/packages/flutter/test/rendering/debug_overflow_indicator_test.dart @@ -21,12 +21,12 @@ void main() { }); testWidgets('overflow indicator is shown when overflowing', (WidgetTester tester) async { - final UnconstrainedBox box = const UnconstrainedBox( + const UnconstrainedBox box = const UnconstrainedBox( child: const SizedBox(width: 200.0, height: 200.0), ); await tester.pumpWidget( - new Center( - child: new SizedBox( + const Center( + child: const SizedBox( height: 100.0, child: box, ), @@ -37,8 +37,8 @@ void main() { expect(find.byType(UnconstrainedBox), paints..rect()); await tester.pumpWidget( - new Center( - child: new SizedBox( + const Center( + child: const SizedBox( height: 100.0, child: box, ), diff --git a/packages/flutter/test/rendering/error_test.dart b/packages/flutter/test/rendering/error_test.dart index 7c1e79db54..20b1d76118 100644 --- a/packages/flutter/test/rendering/error_test.dart +++ b/packages/flutter/test/rendering/error_test.dart @@ -10,7 +10,7 @@ import '../rendering/mock_canvas.dart'; /// Unit tests error.dart's usage via ErrorWidget. void main() { - final String errorMessage = 'Some error message'; + const String errorMessage = 'Some error message'; testWidgets('test draw error paragraph', (WidgetTester tester) async { await tester.pumpWidget(new ErrorWidget(new Exception(errorMessage))); diff --git a/packages/flutter/test/rendering/flex_test.dart b/packages/flutter/test/rendering/flex_test.dart index 2633f4fc39..fd5ad3e0da 100644 --- a/packages/flutter/test/rendering/flex_test.dart +++ b/packages/flutter/test/rendering/flex_test.dart @@ -34,7 +34,7 @@ void main() { ); final FlexParentData flexParentData = flexible.parentData; flexParentData.flex = 1; - final BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); + const BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); layout(flex, constraints: viewport); expect(flexible.size.height, equals(0.0)); expect(flex.getMinIntrinsicHeight(100.0), equals(200.0)); @@ -57,7 +57,7 @@ void main() { ); final FlexParentData flexParentData = flexible.parentData; flexParentData.flex = 1; - final BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); + const BoxConstraints viewport = const BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); layout(flex, constraints: viewport); expect(flexible.size.width, equals(0.0)); expect(flex.getMinIntrinsicHeight(100.0), equals(0.0)); @@ -74,7 +74,7 @@ void main() { new RenderAspectRatio(aspectRatio: 1.0), ] ); - final BoxConstraints viewport = const BoxConstraints(maxHeight: 200.0, maxWidth: 1000.0); + const BoxConstraints viewport = const BoxConstraints(maxHeight: 200.0, maxWidth: 1000.0); layout(flex, constraints: viewport); expect(flex.getMaxIntrinsicWidth(200.0), equals(0.0)); }); @@ -292,7 +292,7 @@ void main() { test('MainAxisSize.min inside unconstrained', () { FlutterError.onError = (FlutterErrorDetails details) => throw details.exception; - final BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); + const BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); @@ -337,7 +337,7 @@ void main() { FlutterError.onError = (FlutterErrorDetails details) { exceptions.add(details.exception); }; - final BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); + const BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); @@ -366,7 +366,7 @@ void main() { FlutterError.onError = (FlutterErrorDetails details) { exceptions.add(details.exception); }; - final BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); + const BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); @@ -392,7 +392,7 @@ void main() { }); test('MainAxisSize.min inside tightly constrained', () { - final BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); + const BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); @@ -412,7 +412,7 @@ void main() { }); test('Flex RTL', () { - final BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); + const BoxConstraints square = const BoxConstraints.tightFor(width: 100.0, height: 100.0); final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); diff --git a/packages/flutter/test/rendering/independent_layout_test.dart b/packages/flutter/test/rendering/independent_layout_test.dart index e333ecdb07..c3b9eb1d78 100644 --- a/packages/flutter/test/rendering/independent_layout_test.dart +++ b/packages/flutter/test/rendering/independent_layout_test.dart @@ -31,7 +31,7 @@ class TestLayout { } void main() { - final ViewConfiguration testConfiguration = const ViewConfiguration( + const ViewConfiguration testConfiguration = const ViewConfiguration( size: const Size(800.0, 600.0), devicePixelRatio: 1.0 ); diff --git a/packages/flutter/test/rendering/paragraph_test.dart b/packages/flutter/test/rendering/paragraph_test.dart index 92a7b7783f..46a9863ff7 100644 --- a/packages/flutter/test/rendering/paragraph_test.dart +++ b/packages/flutter/test/rendering/paragraph_test.dart @@ -225,7 +225,7 @@ void main() { }); test('nested TextSpans in paragraph handle textScaleFactor correctly.', () { - final TextSpan testSpan = const TextSpan( + const TextSpan testSpan = const TextSpan( text: 'a', style: const TextStyle( fontSize: 10.0, diff --git a/packages/flutter/test/rendering/relative_rect_test.dart b/packages/flutter/test/rendering/relative_rect_test.dart index ae0146ff7a..7a27a0d39e 100644 --- a/packages/flutter/test/rendering/relative_rect_test.dart +++ b/packages/flutter/test/rendering/relative_rect_test.dart @@ -7,45 +7,45 @@ import 'package:test/test.dart'; void main() { test('RelativeRect.==', () { - final RelativeRect r = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); expect(r, new RelativeRect.fromSize(new Rect.fromLTWH(10.0, 20.0, 0.0, 0.0), const Size(40.0, 60.0))); }); test('RelativeRect.shift', () { - final RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); final RelativeRect r2 = r1.shift(const Offset(5.0, 50.0)); expect(r2, const RelativeRect.fromLTRB(15.0, 70.0, 25.0, -10.0)); }); test('RelativeRect.inflate', () { - final RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); final RelativeRect r2 = r1.inflate(5.0); expect(r2, const RelativeRect.fromLTRB(5.0, 15.0, 25.0, 35.0)); }); test('RelativeRect.deflate', () { - final RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); final RelativeRect r2 = r1.deflate(5.0); expect(r2, const RelativeRect.fromLTRB(15.0, 25.0, 35.0, 45.0)); }); test('RelativeRect.intersect', () { - final RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); - final RelativeRect r2 = const RelativeRect.fromLTRB(0.0, 30.0, 60.0, 0.0); + const RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r2 = const RelativeRect.fromLTRB(0.0, 30.0, 60.0, 0.0); final RelativeRect r3 = r1.intersect(r2); final RelativeRect r4 = r2.intersect(r1); expect(r3, r4); expect(r3, const RelativeRect.fromLTRB(10.0, 30.0, 60.0, 40.0)); }); test('RelativeRect.toRect', () { - final RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); final Rect r2 = r1.toRect(new Rect.fromLTRB(10.0, 20.0, 90.0, 180.0)); expect(r2, new Rect.fromLTRB(10.0, 20.0, 50.0, 120.0)); }); test('RelativeRect.toSize', () { - final RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r1 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); final Size r2 = r1.toSize(const Size(80.0, 160.0)); expect(r2, const Size(40.0, 100.0)); }); test('RelativeRect.lerp', () { final RelativeRect r1 = RelativeRect.fill; - final RelativeRect r2 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); + const RelativeRect r2 = const RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); final RelativeRect r3 = RelativeRect.lerp(r1, r2, 0.5); expect(r3, const RelativeRect.fromLTRB(5.0, 10.0, 15.0, 20.0)); }); diff --git a/packages/flutter/test/rendering/slivers_helpers_test.dart b/packages/flutter/test/rendering/slivers_helpers_test.dart index 2725ccc93f..230e24c4c9 100644 --- a/packages/flutter/test/rendering/slivers_helpers_test.dart +++ b/packages/flutter/test/rendering/slivers_helpers_test.dart @@ -17,7 +17,7 @@ void main() { }); test('SliverConstraints', () { - final SliverConstraints a = const SliverConstraints( + const SliverConstraints a = const SliverConstraints( axisDirection: AxisDirection.down, growthDirection: GrowthDirection.forward, userScrollDirection: ScrollDirection.idle, @@ -45,7 +45,7 @@ void main() { crossAxisExtent: 40.0, viewportMainAxisExtent: 30.0, ); - final SliverConstraints d = const SliverConstraints( + const SliverConstraints d = const SliverConstraints( axisDirection: AxisDirection.up, growthDirection: GrowthDirection.reverse, userScrollDirection: ScrollDirection.forward, diff --git a/packages/flutter/test/rendering/table_border_test.dart b/packages/flutter/test/rendering/table_border_test.dart index 4357c1279e..50d4ce756e 100644 --- a/packages/flutter/test/rendering/table_border_test.dart +++ b/packages/flutter/test/rendering/table_border_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('TableBorder constructor', () { - final TableBorder border1 = const TableBorder( + const TableBorder border1 = const TableBorder( left: const BorderSide(width: 1.0), right: const BorderSide(color: const Color(0xFF00FF00)), verticalInside: const BorderSide(), @@ -69,7 +69,7 @@ void main() { const BorderSide side4 = const BorderSide(width: 4.0, color: const Color(4)); const BorderSide side5 = const BorderSide(width: 5.0, color: const Color(5)); const BorderSide side6 = const BorderSide(width: 6.0, color: const Color(6)); - final TableBorder tableA = const TableBorder( + const TableBorder tableA = const TableBorder( top: side1, right: side2, bottom: side3, diff --git a/packages/flutter/test/rendering/transform_test.dart b/packages/flutter/test/rendering/transform_test.dart index cad402a41a..9d34601fea 100644 --- a/packages/flutter/test/rendering/transform_test.dart +++ b/packages/flutter/test/rendering/transform_test.dart @@ -167,9 +167,9 @@ void main() { Matrix4 rotateAroundXAxis(double a) { // 3D rotation transform with alpha=a - final double x = 1.0; - final double y = 0.0; - final double z = 0.0; + const double x = 1.0; + const double y = 0.0; + const double z = 0.0; final double sc = math.sin(a / 2.0) * math.cos(a / 2.0); final double sq = math.sin(a / 2.0) * math.sin(a / 2.0); return new Matrix4.fromList([ diff --git a/packages/flutter/test/services/text_input_test.dart b/packages/flutter/test/services/text_input_test.dart index 838475dfb3..6c7730ce8c 100644 --- a/packages/flutter/test/services/text_input_test.dart +++ b/packages/flutter/test/services/text_input_test.dart @@ -8,7 +8,7 @@ import 'package:test/test.dart'; void main() { group('TextInputConfiguration', () { test('sets expected defaults', () { - final TextInputConfiguration configuration = const TextInputConfiguration(); + const TextInputConfiguration configuration = const TextInputConfiguration(); expect(configuration.inputType, TextInputType.text); expect(configuration.obscureText, false); expect(configuration.autocorrect, true); @@ -16,7 +16,7 @@ void main() { }); test('serializes to JSON', () async { - final TextInputConfiguration configuration = const TextInputConfiguration( + const TextInputConfiguration configuration = const TextInputConfiguration( inputType: TextInputType.number, obscureText: true, autocorrect: false, diff --git a/packages/flutter/test/widgets/animated_align_test.dart b/packages/flutter/test/widgets/animated_align_test.dart index 74f43e4750..fb86cccd73 100644 --- a/packages/flutter/test/widgets/animated_align_test.dart +++ b/packages/flutter/test/widgets/animated_align_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('AnimatedAlign.debugFillProperties', (WidgetTester tester) async { - final AnimatedAlign box = const AnimatedAlign( + const AnimatedAlign box = const AnimatedAlign( alignment: Alignment.topCenter, curve: Curves.ease, duration: const Duration(milliseconds: 200), diff --git a/packages/flutter/test/widgets/animated_container_test.dart b/packages/flutter/test/widgets/animated_container_test.dart index b218480b82..97434d3bf9 100644 --- a/packages/flutter/test/widgets/animated_container_test.dart +++ b/packages/flutter/test/widgets/animated_container_test.dart @@ -27,11 +27,11 @@ void main() { testWidgets('AnimatedContainer control test', (WidgetTester tester) async { final GlobalKey key = new GlobalKey(); - final BoxDecoration decorationA = const BoxDecoration( + const BoxDecoration decorationA = const BoxDecoration( color: const Color(0xFF00FF00), ); - final BoxDecoration decorationB = const BoxDecoration( + const BoxDecoration decorationB = const BoxDecoration( color: const Color(0xFF0000FF), ); diff --git a/packages/flutter/test/widgets/binding_test.dart b/packages/flutter/test/widgets/binding_test.dart index 52ccb89823..907be29576 100644 --- a/packages/flutter/test/widgets/binding_test.dart +++ b/packages/flutter/test/widgets/binding_test.dart @@ -76,9 +76,9 @@ void main() { final PushRouteObserver observer = new PushRouteObserver(); WidgetsBinding.instance.addObserver(observer); - final String testRouteName = 'testRouteName'; + const String testRouteName = 'testRouteName'; final ByteData message = const JSONMethodCodec().encodeMethodCall( - new MethodCall('pushRoute', testRouteName)); + const MethodCall('pushRoute', testRouteName)); await BinaryMessages.handlePlatformMessage('flutter/navigation', message, (_) {}); expect(observer.pushedRoute, testRouteName); diff --git a/packages/flutter/test/widgets/box_decoration_test.dart b/packages/flutter/test/widgets/box_decoration_test.dart index 8c48b0b2d4..be4d43d9bd 100644 --- a/packages/flutter/test/widgets/box_decoration_test.dart +++ b/packages/flutter/test/widgets/box_decoration_test.dart @@ -104,7 +104,7 @@ Future main() async { }); testWidgets('Bordered Container insets its child', (WidgetTester tester) async { - final Key key = const Key('outerContainer'); + const Key key = const Key('outerContainer'); await tester.pumpWidget( new Center( child: new Container( @@ -123,7 +123,7 @@ Future main() async { testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/7672 - final Key key = const Key('Container with BoxDecoration'); + const Key key = const Key('Container with BoxDecoration'); Widget buildFrame(Border border) { return new Center( child: new Container( @@ -135,7 +135,7 @@ Future main() async { ); } - final Color black = const Color(0xFF000000); + const Color black = const Color(0xFF000000); await tester.pumpWidget(buildFrame(new Border.all())); expect(find.byKey(key), paints @@ -145,25 +145,25 @@ Future main() async { expect(find.byKey(key), paints ..rect(color: black, style: PaintingStyle.stroke, strokeWidth: 0.0)); - final Color green = const Color(0xFF00FF00); - final BorderSide greenSide = new BorderSide(color: green, width: 10.0); + const Color green = const Color(0xFF00FF00); + const BorderSide greenSide = const BorderSide(color: green, width: 10.0); - await tester.pumpWidget(buildFrame(new Border(top: greenSide))); + await tester.pumpWidget(buildFrame(const Border(top: greenSide))); expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill)); - await tester.pumpWidget(buildFrame(new Border(left: greenSide))); + await tester.pumpWidget(buildFrame(const Border(left: greenSide))); expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill)); - await tester.pumpWidget(buildFrame(new Border(right: greenSide))); + await tester.pumpWidget(buildFrame(const Border(right: greenSide))); expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill)); - await tester.pumpWidget(buildFrame(new Border(bottom: greenSide))); + await tester.pumpWidget(buildFrame(const Border(bottom: greenSide))); expect(find.byKey(key), paints..path(color: green, style: PaintingStyle.fill)); - final Color blue = const Color(0xFF0000FF); - final BorderSide blueSide = new BorderSide(color: blue, width: 0.0); + const Color blue = const Color(0xFF0000FF); + const BorderSide blueSide = const BorderSide(color: blue, width: 0.0); - await tester.pumpWidget(buildFrame(new Border(top: blueSide, right: greenSide, bottom: greenSide))); + await tester.pumpWidget(buildFrame(const Border(top: blueSide, right: greenSide, bottom: greenSide))); expect(find.byKey(key), paints ..path() // There's not much point checking the arguments to these calls because paintBorder ..path() // reuses the same Paint object each time, configured differently, and so they will @@ -268,7 +268,7 @@ Future main() async { List itemsTapped; - final Key key = const Key('Container with BoxDecoration'); + const Key key = const Key('Container with BoxDecoration'); Widget buildFrame(Border border) { itemsTapped = []; return new Center( @@ -305,7 +305,7 @@ Future main() async { List itemsTapped; - final Key key = const Key('Container with BoxDecoration'); + const Key key = const Key('Container with BoxDecoration'); Widget buildFrame(Border border) { itemsTapped = []; return new Center( diff --git a/packages/flutter/test/widgets/column_test.dart b/packages/flutter/test/widgets/column_test.dart index bfe832bdf8..a10bcf3e85 100644 --- a/packages/flutter/test/widgets/column_test.dart +++ b/packages/flutter/test/widgets/column_test.dart @@ -10,10 +10,10 @@ void main() { // DOWN (default) testWidgets('Column with one flexible child', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -56,10 +56,10 @@ void main() { }); testWidgets('Column with default main axis parameters', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -102,9 +102,9 @@ void main() { }); testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const 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 @@ -140,10 +140,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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. @@ -186,10 +186,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -232,11 +232,11 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async { - 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'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); + const 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 @@ -286,10 +286,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -332,7 +332,7 @@ void main() { }); testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async { - final Key flexKey = const Key('flexKey'); + const 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( @@ -365,7 +365,7 @@ void main() { }); testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async { - final Key childKey = const Key('childKey'); + const Key childKey = const Key('childKey'); await tester.pumpWidget(new Center( child: new Container( @@ -393,10 +393,10 @@ void main() { // UP testWidgets('Column with one flexible child', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -440,10 +440,10 @@ void main() { }); testWidgets('Column with default main axis parameters', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -487,9 +487,9 @@ void main() { }); testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 200, 300 from bottom @@ -526,10 +526,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 300, 400, 500 from bottom. @@ -573,10 +573,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 0, 250, 500 from bottom @@ -620,11 +620,11 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async { - 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'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); + const Key child3Key = const Key('child3'); // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 25, 175, 325, 475 from bottom @@ -675,10 +675,10 @@ void main() { }); testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async { - final Key columnKey = const Key('column'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key columnKey = const Key('column'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x20 children's bottom edges should be at 135, 290, 445 from bottom @@ -722,7 +722,7 @@ void main() { }); testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async { - final Key flexKey = const Key('flexKey'); + const 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( @@ -757,7 +757,7 @@ void main() { }); testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async { - final Key childKey = const Key('childKey'); + const Key childKey = const Key('childKey'); await tester.pumpWidget(new Center( child: new Container( diff --git a/packages/flutter/test/widgets/dismissible_test.dart b/packages/flutter/test/widgets/dismissible_test.dart index beb5c29fd3..eb8070ea8b 100644 --- a/packages/flutter/test/widgets/dismissible_test.dart +++ b/packages/flutter/test/widgets/dismissible_test.dart @@ -539,7 +539,7 @@ void main() { await tester.pumpWidget(buildTest()); final Offset location = tester.getTopLeft(find.text('0')); - final Offset offset = const Offset(0.0, 5.0); + const Offset offset = const Offset(0.0, 5.0); final TestGesture gesture = await tester.startGesture(location, pointer: 5); await gesture.moveBy(offset); await tester.pumpWidget(buildTest()); diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index e20fd28abf..8d3f977435 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -17,8 +17,8 @@ void main() { final TextEditingController controller = new TextEditingController(); final FocusNode focusNode = new FocusNode(); final FocusScopeNode focusScopeNode = new FocusScopeNode(); - final TextStyle textStyle = const TextStyle(); - final Color cursorColor = const Color.fromARGB(0xFF, 0xFF, 0x00, 0x00); + const TextStyle textStyle = const TextStyle(); + const Color cursorColor = const Color.fromARGB(0xFF, 0xFF, 0x00, 0x00); setUp(() { debugResetSemanticsIdCounter(); diff --git a/packages/flutter/test/widgets/form_test.dart b/packages/flutter/test/widgets/form_test.dart index d5827e2cb6..d757cf30db 100644 --- a/packages/flutter/test/widgets/form_test.dart +++ b/packages/flutter/test/widgets/form_test.dart @@ -166,7 +166,7 @@ void main() { }); testWidgets('Provide initial value to input when no controller is specified', (WidgetTester tester) async { - final String initialValue = 'hello'; + const String initialValue = 'hello'; final GlobalKey> inputKey = new GlobalKey>(); Widget builder() { @@ -206,7 +206,7 @@ void main() { testWidgets('Provide initial value to input when controller is specified', (WidgetTester tester) async { final TextEditingController controller = new TextEditingController(); - final String initialValue = 'hello'; + const String initialValue = 'hello'; final GlobalKey> inputKey = new GlobalKey>(); Widget builder() { diff --git a/packages/flutter/test/widgets/gesture_detector_test.dart b/packages/flutter/test/widgets/gesture_detector_test.dart index 679a78a5fe..a779bd9a7e 100644 --- a/packages/flutter/test/widgets/gesture_detector_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_test.dart @@ -33,14 +33,14 @@ void main() { expect(updatedDragDelta, isNull); expect(didEndDrag, isFalse); - final Offset firstLocation = const Offset(10.0, 10.0); + const Offset firstLocation = const Offset(10.0, 10.0); final TestGesture gesture = await tester.startGesture(firstLocation, pointer: 7); expect(didStartDrag, isTrue); didStartDrag = false; expect(updatedDragDelta, isNull); expect(didEndDrag, isFalse); - final Offset secondLocation = const Offset(10.0, 9.0); + const Offset secondLocation = const Offset(10.0, 9.0); await gesture.moveTo(secondLocation); expect(didStartDrag, isFalse); expect(updatedDragDelta, -1.0); @@ -60,8 +60,8 @@ void main() { int gestureCount = 0; double dragDistance = 0.0; - final Offset downLocation = const Offset(10.0, 10.0); - final Offset upLocation = const Offset(10.0, 50.0); // must be far enough to be more than kTouchSlop + const Offset downLocation = const Offset(10.0, 10.0); + const Offset upLocation = const Offset(10.0, 50.0); // must be far enough to be more than kTouchSlop final Widget widget = new GestureDetector( onVerticalDragUpdate: (DragUpdateDetails details) { dragDistance += details.primaryDelta; }, diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index b334951afe..248bc489dc 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -258,12 +258,12 @@ void main() { // Expect the height of the secondKey Hero to vary from 100 to 150 // over duration and according to curve. - final Duration duration = const Duration(milliseconds: 300); + const Duration duration = const Duration(milliseconds: 300); final Curve curve = Curves.fastOutSlowIn; final double initialHeight = tester.getSize(find.byKey(firstKey, skipOffstage: false)).height; final double finalHeight = tester.getSize(find.byKey(secondKey, skipOffstage: false)).height; final double deltaHeight = finalHeight - initialHeight; - final double epsilon = 0.001; + const double epsilon = 0.001; await tester.pump(duration * 0.25); expect( @@ -505,7 +505,7 @@ void main() { // Hero a's return flight at 149ms. The outgoing (push) flight took // 150ms so we should be just about back to where Hero 'a' started. - final double epsilon = 0.001; + const double epsilon = 0.001; await tester.pump(const Duration(milliseconds: 99)); closeTo(tester.getSize(find.byKey(secondKey)).height - initialHeight, epsilon); @@ -575,7 +575,7 @@ void main() { // Hero a's return flight at 149ms. The outgoing (push) flight took // 150ms so we should be just about back to where Hero 'a' started. - final double epsilon = 0.001; + const double epsilon = 0.001; await tester.pump(const Duration(milliseconds: 99)); closeTo(tester.getSize(find.byKey(firstKey)).height - initialHeight, epsilon); @@ -587,8 +587,8 @@ void main() { }); testWidgets('Destination hero disappears mid-flight', (WidgetTester tester) async { - final Key homeHeroKey = const Key('home hero'); - final Key routeHeroKey = const Key('route hero'); + const Key homeHeroKey = const Key('home hero'); + const Key routeHeroKey = const Key('route hero'); bool routeIncludesHero = true; StateSetter heroCardSetState; @@ -690,9 +690,9 @@ void main() { }); testWidgets('Destination hero scrolls mid-flight', (WidgetTester tester) async { - final Key homeHeroKey = const Key('home hero'); - final Key routeHeroKey = const Key('route hero'); - final Key routeContainerKey = const Key('route hero container'); + const Key homeHeroKey = const Key('home hero'); + const Key routeHeroKey = const Key('route hero'); + const Key routeContainerKey = const Key('route hero container'); // Show a 200x200 Hero tagged 'H', with key routeHeroKey final MaterialPageRoute route = new MaterialPageRoute( @@ -772,9 +772,9 @@ void main() { }); testWidgets('Destination hero scrolls out of view mid-flight', (WidgetTester tester) async { - final Key homeHeroKey = const Key('home hero'); - final Key routeHeroKey = const Key('route hero'); - final Key routeContainerKey = const Key('route hero container'); + const Key homeHeroKey = const Key('home hero'); + const Key routeHeroKey = const Key('route hero'); + const Key routeContainerKey = const Key('route hero container'); // Show a 200x200 Hero tagged 'H', with key routeHeroKey final MaterialPageRoute route = new MaterialPageRoute( @@ -851,8 +851,8 @@ void main() { testWidgets('Aborted flight', (WidgetTester tester) async { // See https://github.com/flutter/flutter/issues/5798 - final Key heroABKey = const Key('AB hero'); - final Key heroBCKey = const Key('BC hero'); + const Key heroABKey = const Key('AB hero'); + const Key heroBCKey = const Key('BC hero'); // Show a 150x150 Hero tagged 'BC' final MaterialPageRoute routeC = new MaterialPageRoute( @@ -1084,8 +1084,8 @@ void main() { await tester.pumpWidget(new MaterialApp(routes: createRectTweenHeroRoutes)); expect(tester.getCenter(find.byKey(firstKey)), const Offset(50.0, 50.0)); - final double epsilon = 0.001; - final Duration duration = const Duration(milliseconds: 300); + const double epsilon = 0.001; + const Duration duration = const Duration(milliseconds: 300); final Curve curve = Curves.fastOutSlowIn; final MaterialPointArcTween pushCenterTween = new MaterialPointArcTween( begin: const Offset(50.0, 50.0), @@ -1156,8 +1156,8 @@ void main() { await tester.tap(find.text('twoInset')); await tester.pump(); // begin navigation from / to /twoInset. - final double epsilon = 0.001; - final Duration duration = const Duration(milliseconds: 300); + const double epsilon = 0.001; + const Duration duration = const Duration(milliseconds: 300); await tester.pump(); final double x0 = tester.getTopLeft(find.byKey(secondKey)).dx; diff --git a/packages/flutter/test/widgets/hyperlink_test.dart b/packages/flutter/test/widgets/hyperlink_test.dart index 6f6fede85f..b265d318e6 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; }; - final Key textKey = const Key('text'); + const Key textKey = const Key('text'); await tester.pumpWidget( new Center( diff --git a/packages/flutter/test/widgets/icon_theme_data_test.dart b/packages/flutter/test/widgets/icon_theme_data_test.dart index cc55803d7f..c909224a31 100644 --- a/packages/flutter/test/widgets/icon_theme_data_test.dart +++ b/packages/flutter/test/widgets/icon_theme_data_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('IconThemeData control test', () { - final IconThemeData data = const IconThemeData(color: const Color(0xAAAAAAAA), opacity: 0.5, size: 16.0); + const IconThemeData data = const IconThemeData(color: const Color(0xAAAAAAAA), opacity: 0.5, size: 16.0); expect(data, hasOneLineDescription); expect(data, equals(data.copyWith())); diff --git a/packages/flutter/test/widgets/image_package_asset_test.dart b/packages/flutter/test/widgets/image_package_asset_test.dart index 15f26102ce..4383d2d239 100644 --- a/packages/flutter/test/widgets/image_package_asset_test.dart +++ b/packages/flutter/test/widgets/image_package_asset_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('AssetImage from package', () { - final AssetImage image = const AssetImage( + const AssetImage image = const AssetImage( 'assets/image.png', package: 'test_package', ); @@ -15,7 +15,7 @@ void main() { }); test('ExactAssetImage from package', () { - final ExactAssetImage image = const ExactAssetImage( + const ExactAssetImage image = const ExactAssetImage( 'assets/image.png', scale: 1.5, package: 'test_package', diff --git a/packages/flutter/test/widgets/image_resolution_test.dart b/packages/flutter/test/widgets/image_resolution_test.dart index dc7138d3d9..95e73337c1 100644 --- a/packages/flutter/test/widgets/image_resolution_test.dart +++ b/packages/flutter/test/widgets/image_resolution_test.dart @@ -150,13 +150,13 @@ TestImage getTestImage(WidgetTester tester, Key key) { } Future pumpTreeToLayout(WidgetTester tester, Widget widget) { - final Duration pumpDuration = const Duration(milliseconds: 0); + const Duration pumpDuration = const Duration(milliseconds: 0); final EnginePhase pumpPhase = EnginePhase.layout; return tester.pumpWidget(widget, pumpDuration, pumpPhase); } void main() { - final String image = 'assets/image.png'; + const String image = 'assets/image.png'; testWidgets('Image for device pixel ratio 1.0', (WidgetTester tester) async { const double ratio = 1.0; diff --git a/packages/flutter/test/widgets/list_view_misc_test.dart b/packages/flutter/test/widgets/list_view_misc_test.dart index 85b15f8405..c3898d6dff 100644 --- a/packages/flutter/test/widgets/list_view_misc_test.dart +++ b/packages/flutter/test/widgets/list_view_misc_test.dart @@ -100,7 +100,7 @@ void main() { await tester.pumpWidget(buildBlock(reverse: true)); - final Offset target = const Offset(200.0, 200.0); + const Offset target = const Offset(200.0, 200.0); await tester.tapAt(target); expect(first, equals(0)); expect(second, equals(1)); diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index ed8ac80e20..5f81f5070c 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -165,7 +165,7 @@ void main() { }); testWidgets('Navigator.of fails gracefully when not found in context', (WidgetTester tester) async { - final Key targetKey = const Key('foo'); + const Key targetKey = const Key('foo'); dynamic exception; final Widget widget = new ThirdWidget( targetKey: targetKey, diff --git a/packages/flutter/test/widgets/page_forward_transitions_test.dart b/packages/flutter/test/widgets/page_forward_transitions_test.dart index b65a794112..fbd796e156 100644 --- a/packages/flutter/test/widgets/page_forward_transitions_test.dart +++ b/packages/flutter/test/widgets/page_forward_transitions_test.dart @@ -50,8 +50,8 @@ class TestRoute extends PageRoute { } void main() { - final Duration kTwoTenthsOfTheTransitionDuration = const Duration(milliseconds: 30); - final Duration kFourTenthsOfTheTransitionDuration = const Duration(milliseconds: 60); + const Duration kTwoTenthsOfTheTransitionDuration = const Duration(milliseconds: 30); + const Duration kFourTenthsOfTheTransitionDuration = const Duration(milliseconds: 60); testWidgets('Check onstage/offstage handling around transitions', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/page_storage_test.dart b/packages/flutter/test/widgets/page_storage_test.dart index fbe0d08881..e6feb1fad7 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 = const PageStorageKey('builderKey'); + const Key builderKey = const PageStorageKey('builderKey'); StateSetter setState; int storedValue = 0; diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index c5cec27d07..418675e31d 100644 --- a/packages/flutter/test/widgets/parent_data_test.dart +++ b/packages/flutter/test/widgets/parent_data_test.dart @@ -96,20 +96,20 @@ void main() { kNonPositioned, ]); - final DecoratedBox kDecoratedBoxA = const DecoratedBox(decoration: kBoxDecorationA); - final DecoratedBox kDecoratedBoxB = const DecoratedBox(decoration: kBoxDecorationB); - final DecoratedBox kDecoratedBoxC = const DecoratedBox(decoration: kBoxDecorationC); + const DecoratedBox kDecoratedBoxA = const DecoratedBox(decoration: kBoxDecorationA); + const DecoratedBox kDecoratedBoxB = const DecoratedBox(decoration: kBoxDecorationB); + const DecoratedBox kDecoratedBoxC = const DecoratedBox(decoration: kBoxDecorationC); await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, - children: [ - new Positioned( + children: const [ + const Positioned( bottom: 5.0, right: 7.0, child: kDecoratedBoxA, ), - new Positioned( + const Positioned( top: 10.0, left: 10.0, child: kDecoratedBoxB, @@ -128,13 +128,13 @@ void main() { await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, - children: [ - new Positioned( + children: const [ + const Positioned( bottom: 6.0, right: 8.0, child: kDecoratedBoxA, ), - new Positioned( + const Positioned( left: 10.0, right: 10.0, child: kDecoratedBoxB, @@ -181,7 +181,7 @@ void main() { child: new Container(child: kDecoratedBoxB), ), new Container( - child: new Positioned( + child: const Positioned( top: 8.0, child: kDecoratedBoxC, ), @@ -199,10 +199,10 @@ void main() { await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, - children: [ - new Positioned( + children: const [ + const Positioned( right: 10.0, - child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB), + child: const FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB), ), ], ), @@ -222,10 +222,10 @@ void main() { await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, - children: [ - new Positioned( + children: const [ + const Positioned( top: 7.0, - child: new FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB), + child: const FlipWidget(left: kDecoratedBoxA, right: kDecoratedBoxB), ), ], ), diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 48eb99c483..ef352d6107 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -53,7 +53,7 @@ void main() { final GlobalKey left = new GlobalKey(); final GlobalKey right = new GlobalKey(); - final StateMarker grandchild = const StateMarker(); + const StateMarker grandchild = const StateMarker(); await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, @@ -80,7 +80,7 @@ void main() { expect(grandchildState, isNotNull); grandchildState.marker = 'grandchild'; - final StateMarker newGrandchild = const StateMarker(); + const StateMarker newGrandchild = const StateMarker(); await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, @@ -128,7 +128,7 @@ void main() { final GlobalKey left = new GlobalKey(); final GlobalKey right = new GlobalKey(); - final StateMarker grandchild = const StateMarker(); + const StateMarker grandchild = const StateMarker(); await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, @@ -151,7 +151,7 @@ void main() { expect(grandchildState, isNotNull); grandchildState.marker = 'grandchild'; - final StateMarker newGrandchild = const StateMarker(); + const StateMarker newGrandchild = const StateMarker(); await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index 38e501d7e5..9de6b12455 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -98,7 +98,7 @@ Future runNavigatorTest( void main() { testWidgets('Route settings', (WidgetTester tester) async { - final RouteSettings settings = const RouteSettings(name: 'A'); + const RouteSettings settings = const RouteSettings(name: 'A'); expect(settings, hasOneLineDescription); final RouteSettings settings2 = settings.copyWith(name: 'B'); expect(settings2.name, 'B'); diff --git a/packages/flutter/test/widgets/row_test.dart b/packages/flutter/test/widgets/row_test.dart index 1220e5d58d..ae3a1a72a2 100644 --- a/packages/flutter/test/widgets/row_test.dart +++ b/packages/flutter/test/widgets/row_test.dart @@ -30,10 +30,10 @@ void main() { testWidgets('Row with one Flexible child - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -61,10 +61,10 @@ void main() { testWidgets('Row with default main axis parameters - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -92,9 +92,9 @@ void main() { testWidgets('Row with MainAxisAlignment.center - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -122,10 +122,10 @@ void main() { testWidgets('Row with MainAxisAlignment.end - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -154,10 +154,10 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceBetween - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -186,11 +186,11 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceAround - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - 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'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); + const Key child3Key = const Key('child3'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -220,10 +220,10 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceEvenly - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -252,9 +252,9 @@ void main() { testWidgets('Row and MainAxisSize.min - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('rowKey'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key rowKey = const Key('rowKey'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); final FlutterExceptionHandler oldHandler = FlutterError.onError; dynamic exception; @@ -282,7 +282,7 @@ void main() { testWidgets('Row MainAxisSize.min layout at zero size - no textDirection', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key childKey = const Key('childKey'); + const Key childKey = const Key('childKey'); await tester.pumpWidget(new Center( child: new Container( @@ -312,10 +312,10 @@ void main() { testWidgets('Row with one Flexible child - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -362,10 +362,10 @@ void main() { testWidgets('Row with default main axis parameters - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -412,9 +412,9 @@ void main() { testWidgets('Row with MainAxisAlignment.center - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const 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 @@ -454,10 +454,10 @@ void main() { testWidgets('Row with MainAxisAlignment.end - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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. @@ -504,10 +504,10 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceBetween - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -554,11 +554,11 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceAround - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - 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'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); + const 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 @@ -612,10 +612,10 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceEvenly - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -662,9 +662,9 @@ void main() { testWidgets('Row and MainAxisSize.min - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('rowKey'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key rowKey = const Key('rowKey'); + const Key child0Key = const Key('child0'); + const 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. @@ -704,7 +704,7 @@ void main() { testWidgets('Row MainAxisSize.min layout at zero size - LTR', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key childKey = const Key('childKey'); + const Key childKey = const Key('childKey'); await tester.pumpWidget(new Center( child: new Container( @@ -735,10 +735,10 @@ void main() { testWidgets('Row with one Flexible child - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -785,10 +785,10 @@ void main() { testWidgets('Row with default main axis parameters - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const 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 @@ -835,9 +835,9 @@ void main() { testWidgets('Row with MainAxisAlignment.center - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 300, 400 from the right @@ -877,10 +877,10 @@ void main() { testWidgets('Row with MainAxisAlignment.end - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 500, 600, 700 from the right. @@ -927,10 +927,10 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceBetween - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 0, 350, 700 from the right @@ -977,11 +977,11 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceAround - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - 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'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); + const Key child3Key = const Key('child3'); // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 50, 250, 450, 650 from the right @@ -1035,10 +1035,10 @@ void main() { testWidgets('Row with MainAxisAlignment.spaceEvenly - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('row'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); - final Key child2Key = const Key('child2'); + const Key rowKey = const Key('row'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); + const Key child2Key = const Key('child2'); // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 200x100 children's right edges should be at 50, 300, 550 from the right @@ -1085,9 +1085,9 @@ void main() { testWidgets('Row and MainAxisSize.min - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key rowKey = const Key('rowKey'); - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key rowKey = const Key('rowKey'); + const Key child0Key = const Key('child0'); + const 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 from right. @@ -1127,7 +1127,7 @@ void main() { testWidgets('Row MainAxisSize.min layout at zero size - RTL', (WidgetTester tester) async { OrderPainter.log.clear(); - final Key childKey = const Key('childKey'); + const Key childKey = const Key('childKey'); await tester.pumpWidget(new Center( child: new Container( diff --git a/packages/flutter/test/widgets/rtl_test.dart b/packages/flutter/test/widgets/rtl_test.dart index f129ba9a78..e164e55944 100644 --- a/packages/flutter/test/widgets/rtl_test.dart +++ b/packages/flutter/test/widgets/rtl_test.dart @@ -7,16 +7,16 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Padding RTL', (WidgetTester tester) async { - final Widget child = const Padding( + const Widget child = const Padding( padding: const EdgeInsetsDirectional.only(start: 10.0), child: const Placeholder(), ); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: child, )); expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(10.0, 0.0)); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.rtl, child: child, )); diff --git a/packages/flutter/test/widgets/safe_area_test.dart b/packages/flutter/test/widgets/safe_area_test.dart index 3eb7d3ba7a..1703535bd2 100644 --- a/packages/flutter/test/widgets/safe_area_test.dart +++ b/packages/flutter/test/widgets/safe_area_test.dart @@ -39,7 +39,7 @@ void main() { }); testWidgets('SafeArea - changing', (WidgetTester tester) async { - final Widget child = const SafeArea( + const Widget child = const SafeArea( bottom: false, child: const SafeArea( left: false, @@ -48,7 +48,7 @@ void main() { ), ); await tester.pumpWidget( - new MediaQuery( + const MediaQuery( data: const MediaQueryData(padding: const EdgeInsets.all(20.0)), child: child, ), @@ -56,7 +56,7 @@ void main() { expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(20.0, 20.0)); expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(780.0, 600.0)); await tester.pumpWidget( - new MediaQuery( + const MediaQuery( data: const MediaQueryData(padding: const EdgeInsets.only( left: 100.0, top: 30.0, diff --git a/packages/flutter/test/widgets/scrollable_grid_test.dart b/packages/flutter/test/widgets/scrollable_grid_test.dart index b5beb7bbe6..66eb536f9b 100644 --- a/packages/flutter/test/widgets/scrollable_grid_test.dart +++ b/packages/flutter/test/widgets/scrollable_grid_test.dart @@ -22,7 +22,7 @@ void main() { // Tests https://github.com/flutter/flutter/issues/5522 testWidgets('GridView displays correct children with nonzero padding', (WidgetTester tester) async { - final EdgeInsets padding = const EdgeInsets.fromLTRB(0.0, 100.0, 0.0, 0.0); + const EdgeInsets padding = const EdgeInsets.fromLTRB(0.0, 100.0, 0.0, 0.0); final Widget testWidget = new Directionality( textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/widgets/sized_box_test.dart b/packages/flutter/test/widgets/sized_box_test.dart index 9bd7459d4a..b9a50e227a 100644 --- a/packages/flutter/test/widgets/sized_box_test.dart +++ b/packages/flutter/test/widgets/sized_box_test.dart @@ -7,15 +7,15 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('SizedBox constructors', (WidgetTester tester) async { - final SizedBox a = const SizedBox(); + const SizedBox a = const SizedBox(); expect(a.width, isNull); expect(a.height, isNull); - final SizedBox b = const SizedBox(width: 10.0); + const SizedBox b = const SizedBox(width: 10.0); expect(b.width, 10.0); expect(b.height, isNull); - final SizedBox c = const SizedBox(width: 10.0, height: 20.0); + const SizedBox c = const SizedBox(width: 10.0, height: 20.0); expect(c.width, 10.0); expect(c.height, 20.0); @@ -27,7 +27,7 @@ void main() { expect(e.width, 1.0); expect(e.height, 2.0); - final SizedBox f = const SizedBox.expand(); + const SizedBox f = const SizedBox.expand(); expect(f.width, double.INFINITY); expect(f.height, double.INFINITY); }); diff --git a/packages/flutter/test/widgets/slivers_padding_test.dart b/packages/flutter/test/widgets/slivers_padding_test.dart index cf27fa3854..08c640ba5b 100644 --- a/packages/flutter/test/widgets/slivers_padding_test.dart +++ b/packages/flutter/test/widgets/slivers_padding_test.dart @@ -39,7 +39,7 @@ void verify(WidgetTester tester, List answerKey) { void main() { testWidgets('Viewport+SliverPadding basic test (VISUAL)', (WidgetTester tester) async { - final EdgeInsets padding = const EdgeInsets.fromLTRB(25.0, 20.0, 15.0, 35.0); + const EdgeInsets padding = const EdgeInsets.fromLTRB(25.0, 20.0, 15.0, 35.0); await test(tester, 0.0, padding, AxisDirection.down, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ @@ -78,7 +78,7 @@ void main() { }); testWidgets('Viewport+SliverPadding basic test (LTR)', (WidgetTester tester) async { - final EdgeInsetsDirectional padding = const EdgeInsetsDirectional.fromSTEB(25.0, 20.0, 15.0, 35.0); + const EdgeInsetsDirectional padding = const EdgeInsetsDirectional.fromSTEB(25.0, 20.0, 15.0, 35.0); await test(tester, 0.0, padding, AxisDirection.down, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ @@ -117,7 +117,7 @@ void main() { }); testWidgets('Viewport+SliverPadding basic test (RTL)', (WidgetTester tester) async { - final EdgeInsetsDirectional padding = const EdgeInsetsDirectional.fromSTEB(25.0, 20.0, 15.0, 35.0); + const EdgeInsetsDirectional padding = const EdgeInsetsDirectional.fromSTEB(25.0, 20.0, 15.0, 35.0); await test(tester, 0.0, padding, AxisDirection.down, TextDirection.rtl); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ @@ -156,7 +156,7 @@ void main() { }); testWidgets('Viewport+SliverPadding hit testing', (WidgetTester tester) async { - final EdgeInsets padding = const EdgeInsets.all(30.0); + const EdgeInsets padding = const EdgeInsets.all(30.0); await test(tester, 350.0, padding, AxisDirection.down, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ @@ -178,7 +178,7 @@ void main() { }); testWidgets('Viewport+SliverPadding hit testing up', (WidgetTester tester) async { - final EdgeInsets padding = const EdgeInsets.all(30.0); + const EdgeInsets padding = const EdgeInsets.all(30.0); await test(tester, 350.0, padding, AxisDirection.up, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ @@ -200,7 +200,7 @@ void main() { }); testWidgets('Viewport+SliverPadding hit testing left', (WidgetTester tester) async { - final EdgeInsets padding = const EdgeInsets.all(30.0); + const EdgeInsets padding = const EdgeInsets.all(30.0); await test(tester, 350.0, padding, AxisDirection.left, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ @@ -222,7 +222,7 @@ void main() { }); testWidgets('Viewport+SliverPadding hit testing right', (WidgetTester tester) async { - final EdgeInsets padding = const EdgeInsets.all(30.0); + const EdgeInsets padding = const EdgeInsets.all(30.0); await test(tester, 350.0, padding, AxisDirection.right, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index fac7a88765..2ebec853ef 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -37,7 +37,7 @@ void main() { }); testWidgets('Can change position data', (WidgetTester tester) async { - final Key key = const Key('container'); + const Key key = const Key('container'); await tester.pumpWidget( new Stack( @@ -94,7 +94,7 @@ void main() { }); testWidgets('Can remove parent data', (WidgetTester tester) async { - final Key key = const Key('container'); + const Key key = const Key('container'); final Container container = new Container(key: key, width: 10.0, height: 10.0); await tester.pumpWidget( @@ -132,8 +132,8 @@ void main() { }); testWidgets('Can align non-positioned children (LTR)', (WidgetTester tester) async { - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); await tester.pumpWidget( new Directionality( @@ -178,8 +178,8 @@ void main() { }); testWidgets('Can align non-positioned children (RTL)', (WidgetTester tester) async { - final Key child0Key = const Key('child0'); - final Key child1Key = const Key('child1'); + const Key child0Key = const Key('child0'); + const Key child1Key = const Key('child1'); await tester.pumpWidget( new Directionality( @@ -242,7 +242,7 @@ void main() { }); testWidgets('Can construct an IndexedStack', (WidgetTester tester) async { - final int itemCount = 3; + const int itemCount = 3; List itemsPainted; Widget buildFrame(int index) { @@ -278,8 +278,8 @@ void main() { }); testWidgets('Can hit test an IndexedStack', (WidgetTester tester) async { - final Key key = const Key('indexedStack'); - final int itemCount = 3; + const Key key = const Key('indexedStack'); + const int itemCount = 3; List itemsTapped; Widget buildFrame(int index) { @@ -309,21 +309,21 @@ void main() { }); testWidgets('Can set width and height', (WidgetTester tester) async { - final Key key = const Key('container'); + const Key key = const Key('container'); - final BoxDecoration kBoxDecoration = const BoxDecoration( + const BoxDecoration kBoxDecoration = const BoxDecoration( color: const Color(0xFF00FF00), ); await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, - children: [ - new Positioned( + children: const [ + const Positioned( left: 10.0, width: 11.0, height: 12.0, - child: new DecoratedBox(key: key, decoration: kBoxDecoration), + child: const DecoratedBox(key: key, decoration: kBoxDecoration), ), ], ), @@ -350,12 +350,12 @@ void main() { await tester.pumpWidget( new Stack( textDirection: TextDirection.ltr, - children: [ - new Positioned( + children: const [ + const Positioned( right: 10.0, width: 11.0, height: 12.0, - child: new DecoratedBox(key: key, decoration: kBoxDecoration), + child: const DecoratedBox(key: key, decoration: kBoxDecoration), ), ], ), diff --git a/packages/flutter/test/widgets/stateful_components_test.dart b/packages/flutter/test/widgets/stateful_components_test.dart index b2bae20c16..d9f61c2615 100644 --- a/packages/flutter/test/widgets/stateful_components_test.dart +++ b/packages/flutter/test/widgets/stateful_components_test.dart @@ -45,12 +45,12 @@ class OuterContainerState extends State { void main() { testWidgets('resync stateful widget', (WidgetTester tester) async { - final Key innerKey = const Key('inner'); - final Key outerKey = const Key('outer'); + const Key innerKey = const Key('inner'); + const Key outerKey = const Key('outer'); - final InnerWidget inner1 = new InnerWidget(key: innerKey); + const InnerWidget inner1 = const InnerWidget(key: innerKey); InnerWidget inner2; - final OuterContainer outer1 = new OuterContainer(key: outerKey, child: inner1); + const OuterContainer outer1 = const OuterContainer(key: outerKey, child: inner1); OuterContainer outer2; await tester.pumpWidget(outer1); @@ -61,7 +61,7 @@ void main() { expect(innerElementState._didInitState, isTrue); expect(innerElement.renderObject.attached, isTrue); - inner2 = new InnerWidget(key: innerKey); + inner2 = const InnerWidget(key: innerKey); outer2 = new OuterContainer(key: outerKey, child: inner2); await tester.pumpWidget(outer2); diff --git a/packages/flutter/test/widgets/syncing_test.dart b/packages/flutter/test/widgets/syncing_test.dart index 033cc7c6a5..0f62f57560 100644 --- a/packages/flutter/test/widgets/syncing_test.dart +++ b/packages/flutter/test/widgets/syncing_test.dart @@ -112,8 +112,8 @@ void main() { }); testWidgets('swap instances around', (WidgetTester tester) async { - final Widget a = const TestWidget(persistentState: 0x61, syncedState: 0x41, child: const Text('apple', textDirection: TextDirection.ltr)); - final Widget b = const TestWidget(persistentState: 0x62, syncedState: 0x42, child: const Text('banana', textDirection: TextDirection.ltr)); + const Widget a = const TestWidget(persistentState: 0x61, syncedState: 0x41, child: const Text('apple', textDirection: TextDirection.ltr)); + const Widget b = const TestWidget(persistentState: 0x62, syncedState: 0x42, child: const Text('banana', textDirection: TextDirection.ltr)); await tester.pumpWidget(new Column()); final GlobalKey keyA = new GlobalKey(); diff --git a/packages/flutter/test/widgets/ticker_provider_test.dart b/packages/flutter/test/widgets/ticker_provider_test.dart index 67991c5f0b..1467521476 100644 --- a/packages/flutter/test/widgets/ticker_provider_test.dart +++ b/packages/flutter/test/widgets/ticker_provider_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; void main() { testWidgets('TickerMode', (WidgetTester tester) async { - final Widget widget = const TickerMode( + const Widget widget = const TickerMode( enabled: false, child: const CircularProgressIndicator() ); diff --git a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart index 3ff890bd6c..451e0fafd2 100644 --- a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart +++ b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart @@ -9,7 +9,7 @@ void main() { testWidgets('TrackingScrollController saves offset', (WidgetTester tester) async { final TrackingScrollController controller = new TrackingScrollController(); - final double listItemHeight = 100.0; + const double listItemHeight = 100.0; await tester.pumpWidget( new Directionality( diff --git a/packages/flutter/test/widgets/transitions_test.dart b/packages/flutter/test/widgets/transitions_test.dart index 413b5b5bb3..09138aed2a 100644 --- a/packages/flutter/test/widgets/transitions_test.dart +++ b/packages/flutter/test/widgets/transitions_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('toString control test', (WidgetTester tester) async { - final Widget widget = const FadeTransition( + const Widget widget = const FadeTransition( opacity: kAlwaysCompleteAnimation, child: const Text('Ready', textDirection: TextDirection.ltr), ); diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index 00c31e2270..26e0d207ec 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -269,9 +269,9 @@ void main() { final WidgetInspectorService service = WidgetInspectorService.instance; service.disposeAllGroups(); final Object a = new Object(); - final String group1 = 'group-1'; - final String group2 = 'group-2'; - final String group3 = 'group-3'; + const String group1 = 'group-1'; + const String group2 = 'group-2'; + const String group3 = 'group-3'; final String aId = service.toId(a, group1); expect(service.toId(a, group2), equals(aId)); expect(service.toId(a, group3), equals(aId)); @@ -287,8 +287,8 @@ void main() { service.disposeAllGroups(); final Object a = new Object(); final Object b = new Object(); - final String group1 = 'group-1'; - final String group2 = 'group-2'; + const String group1 = 'group-1'; + const String group2 = 'group-2'; final String aId = service.toId(a, group1); final String bId = service.toId(b, group1); expect(service.toId(a, group2), equals(aId)); @@ -301,8 +301,8 @@ void main() { }); test('WidgetInspectorService toObjectForSourceLocation', () { - final String group = 'test-group'; - final Text widget = const Text('a', textDirection: TextDirection.ltr); + const String group = 'test-group'; + const Text widget = const Text('a', textDirection: TextDirection.ltr); final WidgetInspectorService service = WidgetInspectorService.instance; service.disposeAllGroups(); final String id = service.toId(widget, group); @@ -316,14 +316,14 @@ void main() { }); test('WidgetInspectorService object id test', () { - final Text a = const Text('a', textDirection: TextDirection.ltr); - final Text b = const Text('b', textDirection: TextDirection.ltr); - final Text c = const Text('c', textDirection: TextDirection.ltr); - final Text d = const Text('d', textDirection: TextDirection.ltr); + const Text a = const Text('a', textDirection: TextDirection.ltr); + const Text b = const Text('b', textDirection: TextDirection.ltr); + const Text c = const Text('c', textDirection: TextDirection.ltr); + const Text d = const Text('d', textDirection: TextDirection.ltr); - final String group1 = 'group-1'; - final String group2 = 'group-2'; - final String group3 = 'group-3'; + const String group1 = 'group-1'; + const String group2 = 'group-2'; + const String group3 = 'group-3'; final WidgetInspectorService service = WidgetInspectorService.instance; service.disposeAllGroups(); @@ -397,7 +397,7 @@ void main() { }); testWidgets('WidgetInspectorService getParentChain', (WidgetTester tester) async { - final String group = 'test-group'; + const String group = 'test-group'; await tester.pumpWidget( new Directionality( @@ -454,7 +454,7 @@ void main() { test('WidgetInspectorService getProperties', () { final DiagnosticsNode diagnostic = const Text('a', textDirection: TextDirection.ltr).toDiagnosticsNode(); - final String group = 'group'; + const String group = 'group'; final WidgetInspectorService service = WidgetInspectorService.instance; service.disposeAllGroups(); final String id = service.toId(diagnostic, group); @@ -470,7 +470,7 @@ void main() { }); testWidgets('WidgetInspectorService getChildren', (WidgetTester tester) async { - final String group = 'test-group'; + const String group = 'test-group'; await tester.pumpWidget( new Directionality( diff --git a/packages/flutter_localizations/test/widgets_test.dart b/packages/flutter_localizations/test/widgets_test.dart index aa57d2d185..53e2e17956 100644 --- a/packages/flutter_localizations/test/widgets_test.dart +++ b/packages/flutter_localizations/test/widgets_test.dart @@ -202,7 +202,7 @@ void main() { }); testWidgets('Localizations.localeFor in a WidgetsApp with an explicit locale', (WidgetTester tester) async { - final Locale locale = const Locale('en', 'US'); + const Locale locale = const Locale('en', 'US'); BuildContext pageContext; await tester.pumpWidget( diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index bdf6131c37..1b908df199 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -514,8 +514,8 @@ class _HasGoodToStringDeep extends Matcher { // If a toStringDeep method doesn't properly handle nested values that // contain line breaks it can fail to add the required prefixes to all // lined when toStringDeep is called specifying prefixes. - final String prefixLineOne = 'PREFIX_LINE_ONE____'; - final String prefixOtherLines = 'PREFIX_OTHER_LINES_'; + const String prefixLineOne = 'PREFIX_LINE_ONE____'; + const String prefixOtherLines = 'PREFIX_OTHER_LINES_'; final List prefixIssues = []; String descriptionWithPrefixes = object.toStringDeep(prefixLineOne: prefixLineOne, prefixOtherLines: prefixOtherLines); diff --git a/packages/flutter_test/test/widget_tester_test.dart b/packages/flutter_test/test/widget_tester_test.dart index a9ef219427..644466aeb2 100644 --- a/packages/flutter_test/test/widget_tester_test.dart +++ b/packages/flutter_test/test/widget_tester_test.dart @@ -113,7 +113,7 @@ void main() { testWidgets('fails with a custom description in the message', (WidgetTester tester) async { await tester.pumpWidget(const Text('foo', textDirection: TextDirection.ltr)); - final String customDescription = 'custom description'; + const String customDescription = 'custom description'; TestFailure failure; try { expect(find.byElementPredicate((_) => false, description: customDescription), findsOneWidget); @@ -130,7 +130,7 @@ void main() { testWidgets('fails with a custom description in the message', (WidgetTester tester) async { await tester.pumpWidget(const Text('foo', textDirection: TextDirection.ltr)); - final String customDescription = 'custom description'; + const String customDescription = 'custom description'; TestFailure failure; try { expect(find.byWidgetPredicate((_) => false, description: customDescription), findsOneWidget); diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index a0a19c0040..9c9cac60a2 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -683,7 +683,7 @@ class _AdbLogReader extends DeviceLogReader { _timeOrigin = null; runCommand(device.adbCommandForDevice(args)).then((Process process) { _process = process; - final Utf8Decoder decoder = const Utf8Decoder(allowMalformed: true); + const Utf8Decoder decoder = const Utf8Decoder(allowMalformed: true); _process.stdout.transform(decoder).transform(const LineSplitter()).listen(_onLine); _process.stderr.transform(decoder).transform(const LineSplitter()).listen(_onLine); _process.exitCode.whenComplete(() { diff --git a/packages/flutter_tools/lib/src/base/process_manager.dart b/packages/flutter_tools/lib/src/base/process_manager.dart index 447a3baba5..bb3957853d 100644 --- a/packages/flutter_tools/lib/src/base/process_manager.dart +++ b/packages/flutter_tools/lib/src/base/process_manager.dart @@ -35,7 +35,7 @@ ProcessManager get processManager { void enableRecordingProcessManager(String location) { final ProcessManager originalProcessManager = processManager; final Directory dir = getRecordingSink(location, _kRecordingType); - final ProcessManager delegate = const LocalProcessManager(); + const ProcessManager delegate = const LocalProcessManager(); final RecordingProcessManager manager = new RecordingProcessManager(delegate, dir); addShutdownHook(() async { await manager.flush(finishRunningProcesses: true); diff --git a/packages/flutter_tools/lib/src/commands/analyze_base.dart b/packages/flutter_tools/lib/src/commands/analyze_base.dart index 1661242290..22874b0c4c 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_base.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_base.dart @@ -40,7 +40,7 @@ abstract class AnalyzeBase { } void writeBenchmark(Stopwatch stopwatch, int errorCount, int membersMissingDocumentation) { - final String benchmarkOut = 'analysis_benchmark.json'; + const String benchmarkOut = 'analysis_benchmark.json'; final Map data = { 'time': (stopwatch.elapsedMilliseconds / 1000.0), 'issues': errorCount, diff --git a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart index 273aa72c96..cafc0a6791 100644 --- a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart +++ b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart @@ -251,7 +251,7 @@ class FuchsiaReloadCommand extends FlutterCommand { final Uri vmServiceAddr = isolate.owner.vmService.httpAddress; final String name = isolate.name; final String shortName = name.substring(0, name.indexOf('\$')); - final String main = '\$main-'; + const String main = '\$main-'; final String number = name.substring(name.indexOf(main) + main.length); // The Observatory requires somewhat non-standard URIs that the Uri class diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index d53ebe56e9..5e7b3bc598 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -95,7 +95,7 @@ class TestCommand extends FlutterCommand { ..writeAsStringSync(coverageData, flush: true); printTrace('wrote coverage data to $coveragePath (size=${coverageData.length})'); - final String baseCoverageData = 'coverage/lcov.base.info'; + const String baseCoverageData = 'coverage/lcov.base.info'; if (mergeCoverageData) { if (!platform.isLinux) { printError( diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index 685bd0ed82..040d12c2c9 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -232,7 +232,7 @@ class _FlutterValidator extends DoctorValidator { } bool _genSnapshotRuns(String genSnapshotPath) { - final int kExpectedExitCode = 255; + const int kExpectedExitCode = 255; try { return processManager.runSync([genSnapshotPath]).exitCode == kExpectedExitCode; } catch (error) { @@ -355,7 +355,7 @@ abstract class IntelliJValidator extends DoctorValidator { final Archive archive = new ZipDecoder().decodeBytes(fs.file(jarPath).readAsBytesSync()); final ArchiveFile file = archive.findFile('META-INF/plugin.xml'); final String content = UTF8.decode(file.content); - final String versionStartTag = ''; + const String versionStartTag = ''; final int start = content.indexOf(versionStartTag); final int end = content.indexOf('', start); return content.substring(start + versionStartTag.length, end); diff --git a/packages/flutter_tools/lib/src/ios/code_signing.dart b/packages/flutter_tools/lib/src/ios/code_signing.dart index 2efbfdfb5d..b891e29f52 100644 --- a/packages/flutter_tools/lib/src/ios/code_signing.dart +++ b/packages/flutter_tools/lib/src/ios/code_signing.dart @@ -107,7 +107,7 @@ Future getCodeSigningIdentityDevelopmentTeam({BuildableIOSApp iosApp, bo if (!exitsHappy(const ['which', 'security']) || !exitsHappy(const ['which', 'openssl'])) return null; - final List findIdentityCommand = + const List findIdentityCommand = const ['security', 'find-identity', '-p', 'codesigning', '-v']; final List validCodeSigningIdentities = runCheckedSync(findIdentityCommand) .split('\n') diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index b5b126c4f5..eead7f3ab9 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -528,14 +528,14 @@ Future upgradePbxProjWithFlutterAssets(String app) async { if (lines.any((String line) => line.contains('path = Flutter/flutter_assets'))) return true; - final String l1 = ' 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };'; - final String l2 = ' 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };'; - final String l3 = ' 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };'; - final String l4 = ' 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };'; - final String l5 = ' 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,'; - final String l6 = ' 2D5378251FAA1A9400D5DBA9 /* flutter_assets */,'; - final String l7 = ' 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,'; - final String l8 = ' 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,'; + const String l1 = ' 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };'; + const String l2 = ' 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };'; + const String l3 = ' 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };'; + const String l4 = ' 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };'; + const String l5 = ' 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,'; + const String l6 = ' 2D5378251FAA1A9400D5DBA9 /* flutter_assets */,'; + const String l7 = ' 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,'; + const String l8 = ' 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,'; printStatus("Upgrading project.pbxproj of $app' to include the " @@ -561,10 +561,10 @@ Future upgradePbxProjWithFlutterAssets(String app) async { lines.insert(lines.indexOf(l5) + 1, l6); lines.insert(lines.indexOf(l7) + 1, l8); - final String l9 = ' 9740EEBB1CF902C7004384FC /* app.flx in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB71CF902C7004384FC /* app.flx */; };'; - final String l10 = ' 9740EEB71CF902C7004384FC /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Flutter/app.flx; sourceTree = ""; };'; - final String l11 = ' 9740EEB71CF902C7004384FC /* app.flx */,'; - final String l12 = ' 9740EEBB1CF902C7004384FC /* app.flx in Resources */,'; + const String l9 = ' 9740EEBB1CF902C7004384FC /* app.flx in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB71CF902C7004384FC /* app.flx */; };'; + const String l10 = ' 9740EEB71CF902C7004384FC /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Flutter/app.flx; sourceTree = ""; };'; + const String l11 = ' 9740EEB71CF902C7004384FC /* app.flx */,'; + const String l12 = ' 9740EEBB1CF902C7004384FC /* app.flx in Resources */,'; if (lines.contains(l9)) { printStatus('Removing app.flx from project.pbxproj since it has been ' diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 2dc34909c7..62788d538f 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -570,7 +570,7 @@ void main() { void startTimeoutTimer(), void reportObservatoryUri(Uri uri), }) { - final String observatoryString = 'Observatory listening on '; + const String observatoryString = 'Observatory listening on '; for (Stream> stream in >>[process.stderr, process.stdout]) { diff --git a/packages/flutter_tools/test/android/android_device_test.dart b/packages/flutter_tools/test/android/android_device_test.dart index b4b7474ba1..5ee2c58594 100644 --- a/packages/flutter_tools/test/android/android_device_test.dart +++ b/packages/flutter_tools/test/android/android_device_test.dart @@ -15,7 +15,7 @@ import '../src/context.dart'; void main() { group('android_device', () { testUsingContext('stores the requested id', () { - final String deviceId = '1234'; + const String deviceId = '1234'; final AndroidDevice device = new AndroidDevice(deviceId); expect(device.id, deviceId); }); diff --git a/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart b/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart index ec1a99693b..8c720b5314 100644 --- a/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart +++ b/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart @@ -130,7 +130,7 @@ $fontsSection testUsingContext('App font uses font file from package', () async { establishFlutterRoot(); - final String fontsSection = ''' + const String fontsSection = ''' - family: foo fonts: - asset: packages/test_package/bar @@ -139,10 +139,10 @@ $fontsSection writePackagesFile('test_package:p/p/lib/'); writePubspecFile('p/p/pubspec.yaml', 'test_package'); - final String font = 'bar'; + const String font = 'bar'; writeFontAsset('p/p/lib/', font); - final String expectedFontManifest = + const String expectedFontManifest = '[{"fonts":[{"asset":"packages/test_package/bar"}],"family":"foo"}]'; await buildAndVerifyFonts( [], @@ -155,7 +155,7 @@ $fontsSection testUsingContext('App font uses local font file and package font file', () async { establishFlutterRoot(); - final String fontsSection = ''' + const String fontsSection = ''' - family: foo fonts: - asset: packages/test_package/bar @@ -165,9 +165,9 @@ $fontsSection writePackagesFile('test_package:p/p/lib/'); writePubspecFile('p/p/pubspec.yaml', 'test_package'); - final String packageFont = 'bar'; + const String packageFont = 'bar'; writeFontAsset('p/p/lib/', packageFont); - final String localFont = 'a/bar'; + const String localFont = 'a/bar'; writeFontAsset('', localFont); final String expectedFontManifest = @@ -186,7 +186,7 @@ $fontsSection writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); - final String fontsSection = ''' + const String fontsSection = ''' - family: foo fonts: - asset: a/bar @@ -197,7 +197,7 @@ $fontsSection fontsSection: fontsSection, ); - final String font = 'a/bar'; + const String font = 'a/bar'; writeFontAsset('p/p/', font); final String expectedFontManifest = @@ -216,7 +216,7 @@ $fontsSection writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/'); - final String fontsSection = ''' + const String fontsSection = ''' - family: foo fonts: - asset: packages/test_package2/bar @@ -228,7 +228,7 @@ $fontsSection ); writePubspecFile('p2/p/pubspec.yaml', 'test_package2'); - final String font = 'bar'; + const String font = 'bar'; writeFontAsset('p2/p/lib/', font); final String expectedFontManifest = @@ -248,7 +248,7 @@ $fontsSection writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); - final String pubspec = ''' + const String pubspec = ''' - family: foo fonts: - style: italic @@ -260,7 +260,7 @@ $fontsSection 'test_package', fontsSection: pubspec, ); - final String font = 'a/bar'; + const String font = 'a/bar'; writeFontAsset('p/p/', font); final String expectedFontManifest = @@ -277,7 +277,7 @@ $fontsSection testUsingContext('App uses local font and package font with own font file.', () async { establishFlutterRoot(); - final String fontsSection = ''' + const String fontsSection = ''' - family: foo fonts: - asset: a/bar @@ -294,7 +294,7 @@ $fontsSection fontsSection: fontsSection, ); - final String font = 'a/bar'; + const String font = 'a/bar'; writeFontAsset('', font); writeFontAsset('p/p/', font); diff --git a/packages/flutter_tools/test/asset_bundle_package_test.dart b/packages/flutter_tools/test/asset_bundle_package_test.dart index dc9dfe681f..af1183cb95 100644 --- a/packages/flutter_tools/test/asset_bundle_package_test.dart +++ b/packages/flutter_tools/test/asset_bundle_package_test.dart @@ -125,7 +125,7 @@ $assetsSection final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); await bundle.build(manifestPath: 'pubspec.yaml'); expect(bundle.entries.length, 2); // LICENSE, AssetManifest - final String expectedAssetManifest = '{}'; + const String expectedAssetManifest = '{}'; expect( UTF8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), expectedAssetManifest, @@ -145,7 +145,7 @@ $assetsSection final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); await bundle.build(manifestPath: 'pubspec.yaml'); expect(bundle.entries.length, 2); // LICENSE, AssetManifest - final String expectedAssetManifest = '{}'; + const String expectedAssetManifest = '{}'; expect( UTF8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), expectedAssetManifest, diff --git a/packages/flutter_tools/test/asset_bundle_test.dart b/packages/flutter_tools/test/asset_bundle_test.dart index b485fe637f..64c8763497 100644 --- a/packages/flutter_tools/test/asset_bundle_test.dart +++ b/packages/flutter_tools/test/asset_bundle_test.dart @@ -56,8 +56,8 @@ void main() { // Create a temporary directory and write a single file into it. final Directory tempDir = fs.systemTempDirectory.createTempSync(); final String projectRoot = tempDir.path; - final String assetPath = 'banana.txt'; - final String assetContents = 'banana'; + const String assetPath = 'banana.txt'; + const String assetContents = 'banana'; final File tempFile = fs.file(fs.path.join(projectRoot, assetPath)); tempFile.parent.createSync(recursive: true); tempFile.writeAsBytesSync(UTF8.encode(assetContents)); @@ -111,7 +111,7 @@ void main() { final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); await bundle.build(manifestPath: 'pubspec.yaml'); expect(bundle.entries.length, 1); - final String expectedAssetManifest = '{}'; + const String expectedAssetManifest = '{}'; expect( UTF8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), expectedAssetManifest, diff --git a/packages/flutter_tools/test/base/file_system_test.dart b/packages/flutter_tools/test/base/file_system_test.dart index 9ef00592c7..f39c3253f0 100644 --- a/packages/flutter_tools/test/base/file_system_test.dart +++ b/packages/flutter_tools/test/base/file_system_test.dart @@ -34,7 +34,7 @@ void main() { /// Copies between 2 instances of file systems which is also supported by copyDirectorySync(). test('test directory copy', () async { final MemoryFileSystem sourceMemoryFs = new MemoryFileSystem(); - final String sourcePath = '/some/origin'; + const String sourcePath = '/some/origin'; final Directory sourceDirectory = await sourceMemoryFs.directory(sourcePath).create(recursive: true); sourceMemoryFs.currentDirectory = sourcePath; final File sourceFile1 = sourceMemoryFs.file('some_file.txt')..writeAsStringSync('bleh'); @@ -44,7 +44,7 @@ void main() { // Copy to another memory file system instance. final MemoryFileSystem targetMemoryFs = new MemoryFileSystem(); - final String targetPath = '/some/non-existent/target'; + const String targetPath = '/some/non-existent/target'; final Directory targetDirectory = targetMemoryFs.directory(targetPath); copyDirectorySync(sourceDirectory, targetDirectory); diff --git a/packages/flutter_tools/test/dependency_checker_test.dart b/packages/flutter_tools/test/dependency_checker_test.dart index 224b44d8cd..ecc76df87b 100644 --- a/packages/flutter_tools/test/dependency_checker_test.dart +++ b/packages/flutter_tools/test/dependency_checker_test.dart @@ -95,7 +95,7 @@ void main() { testUsingContext('moved flutter sdk', () async { final Directory destinationPath = fs.systemTempDirectory.createTempSync('dependency_checker_test_'); // Copy the golden input and let the test run in an isolated temporary in-memory file system. - final LocalFileSystem localFileSystem = const LocalFileSystem(); + const LocalFileSystem localFileSystem = const LocalFileSystem(); final Directory sourcePath = localFileSystem.directory(localFileSystem.path.join(dataPath, 'changed_sdk_location')); copyDirectorySync(sourcePath, destinationPath); fs.currentDirectory = destinationPath; diff --git a/packages/flutter_tools/test/devfs_test.dart b/packages/flutter_tools/test/devfs_test.dart index 19eaa3e914..3e802b627d 100644 --- a/packages/flutter_tools/test/devfs_test.dart +++ b/packages/flutter_tools/test/devfs_test.dart @@ -186,7 +186,7 @@ void main() { }); testUsingContext('add new package with double slashes in URI', () async { - final String packageName = 'doubleslashpkg'; + const String packageName = 'doubleslashpkg'; await _createPackage(fs, packageName, 'somefile.txt', doubleSlash: true); final Set fileFilter = new Set(); diff --git a/packages/flutter_tools/test/flutter_manifest_test.dart b/packages/flutter_tools/test/flutter_manifest_test.dart index ee7e0e63b2..56e7a99dfd 100644 --- a/packages/flutter_tools/test/flutter_manifest_test.dart +++ b/packages/flutter_tools/test/flutter_manifest_test.dart @@ -27,7 +27,7 @@ void main() { }); test('has no fonts or assets when the "flutter" section is empty', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -44,7 +44,7 @@ dependencies: }); test('knows if material design is used', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -57,7 +57,7 @@ flutter: }); test('has two assets', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -75,7 +75,7 @@ flutter: }); test('has one font family with one asset', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -93,7 +93,7 @@ flutter: final List fonts = flutterManifest.fonts; expect(fonts.length, 1); final Font font = fonts[0]; - final String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}]}'; + const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}]}'; expect(font.descriptor.toString(), fontDescriptor); expect(font.familyName, 'foo'); final List assets = font.fontAssets; @@ -105,7 +105,7 @@ flutter: }); test('has one font family with a simple asset and one with weight', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -121,12 +121,12 @@ flutter: '''; final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest); - final String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}], family: foo}]'; + const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}], family: foo}]'; expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor); final List fonts = flutterManifest.fonts; expect(fonts.length, 1); final Font font = fonts[0]; - final String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}]}'; + const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}]}'; expect(font.descriptor.toString(), fontDescriptor); expect(font.familyName, 'foo'); final List assets = font.fontAssets; @@ -142,7 +142,7 @@ flutter: }); test('has one font family with a simple asset and one with weight and style', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -159,12 +159,12 @@ flutter: '''; final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest); - final String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo}]'; + const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo}]'; expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor); final List fonts = flutterManifest.fonts; expect(fonts.length, 1); final Font font = fonts[0]; - final String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; + const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; expect(font.descriptor.toString(), fontDescriptor); expect(font.familyName, 'foo'); final List assets = font.fontAssets; @@ -180,7 +180,7 @@ flutter: }); test('has two font families, each with one simple asset and one with weight and style', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -210,7 +210,7 @@ flutter: expect(fonts.length, 2); final Font fooFont = fonts[0]; - final String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; + const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; expect(fooFont.descriptor.toString(), barFontDescriptor); expect(fooFont.familyName, 'foo'); final List fooAassets = fooFont.fontAssets; @@ -225,7 +225,7 @@ flutter: expect(fooFontAsset1.style, 'italic'); final Font barFont = fonts[1]; - final String fontDescriptor = '{family: bar, fonts: [{asset: a/baz}, {weight: 400, style: italic, asset: a/baz}]}'; + const String fontDescriptor = '{family: bar, fonts: [{asset: a/baz}, {weight: 400, style: italic, asset: a/baz}]}'; expect(barFont.descriptor.toString(), fontDescriptor); expect(barFont.familyName, 'bar'); final List barAssets = barFont.fontAssets; @@ -241,7 +241,7 @@ flutter: }); testUsingContext('has only one of two font familes when one declaration is missing the "family" option', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -270,7 +270,7 @@ flutter: final List fonts = flutterManifest.fonts; expect(fonts.length, 1); final Font fooFont = fonts[0]; - final String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; + const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; expect(fooFont.descriptor.toString(), barFontDescriptor); expect(fooFont.familyName, 'foo'); final List fooAassets = fooFont.fontAssets; @@ -286,7 +286,7 @@ flutter: }); testUsingContext('has only one of two font familes when one declaration is missing the "fonts" option', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -310,7 +310,7 @@ flutter: final List fonts = flutterManifest.fonts; expect(fonts.length, 1); final Font fooFont = fonts[0]; - final String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; + const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}'; expect(fooFont.descriptor.toString(), barFontDescriptor); expect(fooFont.familyName, 'foo'); final List fooAassets = fooFont.fontAssets; @@ -326,7 +326,7 @@ flutter: }); testUsingContext('has no font family when declaration is missing the "asset" option', () async { - final String manifest = ''' + const String manifest = ''' name: test dependencies: flutter: @@ -340,7 +340,7 @@ flutter: '''; final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest); - final String expectedFontsDescriptor = '[{fonts: [{weight: 400}], family: foo}]'; + const String expectedFontsDescriptor = '[{fonts: [{weight: 400}], family: foo}]'; expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor); final List fonts = flutterManifest.fonts; expect(fonts.length, 0); diff --git a/packages/flutter_tools/test/ios/mac_test.dart b/packages/flutter_tools/test/ios/mac_test.dart index 3bdd6e20a1..7b59f5eb76 100644 --- a/packages/flutter_tools/test/ios/mac_test.dart +++ b/packages/flutter_tools/test/ios/mac_test.dart @@ -113,7 +113,7 @@ void main() { }); testUsingContext('xcodeSelectPath returns path when xcode-select is installed', () { - final String xcodePath = '/Applications/Xcode8.0.app/Contents/Developer'; + const String xcodePath = '/Applications/Xcode8.0.app/Contents/Developer'; when(mockProcessManager.runSync(['/usr/bin/xcode-select', '--print-path'])) .thenReturn(new ProcessResult(1, 0, xcodePath, '')); expect(xcode.xcodeSelectPath, xcodePath); diff --git a/packages/flutter_tools/test/ios/xcodeproj_test.dart b/packages/flutter_tools/test/ios/xcodeproj_test.dart index a8eeb7fb02..75cec8a0ef 100644 --- a/packages/flutter_tools/test/ios/xcodeproj_test.dart +++ b/packages/flutter_tools/test/ios/xcodeproj_test.dart @@ -6,7 +6,7 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart'; void main() { group('Xcode project properties', () { test('properties from default project can be parsed', () { - final String output = ''' + const String output = ''' Information about project "Runner": Targets: Runner @@ -27,7 +27,7 @@ Information about project "Runner": expect(info.buildConfigurations, ['Debug', 'Release']); }); test('properties from project with custom schemes can be parsed', () { - final String output = ''' + const String output = ''' Information about project "Runner": Targets: Runner