From 6c32c15f3c9bb21966b8ea811e45e73a8a2c9e17 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Fri, 2 Nov 2018 14:25:06 +0100 Subject: [PATCH] add some const classes (#21954) --- .../lib/src/widgets/nested_scroll_view.dart | 2 +- .../lib/src/widgets/platform_view.dart | 3 +- .../flutter/lib/src/widgets/scroll_view.dart | 15 ++- .../src/widgets/single_child_scroll_view.dart | 5 +- .../flutter/test/cupertino/nav_bar_test.dart | 16 +-- .../flutter/test/cupertino/route_test.dart | 4 +- .../test/cupertino/scrollbar_paint_test.dart | 4 +- .../test/cupertino/scrollbar_test.dart | 8 +- .../material/mergeable_material_test.dart | 112 +++++++++--------- .../test/material/scrollbar_paint_test.dart | 8 +- .../flutter/test/material/scrollbar_test.dart | 4 +- .../widgets/overscroll_indicator_test.dart | 52 ++++---- .../test/widgets/platform_view_test.dart | 44 +++---- .../widgets/scroll_notification_test.dart | 6 +- .../test/widgets/scroll_view_test.dart | 6 +- .../flutter/test/widgets/scrollable_test.dart | 4 +- .../single_child_scroll_view_test.dart | 4 +- 17 files changed, 147 insertions(+), 150 deletions(-) diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index fe6058297c..89e94341ca 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -357,7 +357,7 @@ class _NestedScrollViewState extends State { } class _NestedScrollViewCustomScrollView extends CustomScrollView { - _NestedScrollViewCustomScrollView({ + const _NestedScrollViewCustomScrollView({ @required Axis scrollDirection, @required bool reverse, @required ScrollPhysics physics, diff --git a/packages/flutter/lib/src/widgets/platform_view.dart b/packages/flutter/lib/src/widgets/platform_view.dart index 2f04cfd2a3..1e08bf821c 100644 --- a/packages/flutter/lib/src/widgets/platform_view.dart +++ b/packages/flutter/lib/src/widgets/platform_view.dart @@ -58,8 +58,7 @@ class AndroidView extends StatefulWidget { /// The `viewType` and `hitTestBehavior` parameters must not be null. /// If `creationParams` is not null then `creationParamsCodec` must not be null. /// {@endtemplate} - AndroidView({ // ignore: prefer_const_constructors_in_immutables - // TODO(aam): Remove lint ignore above once https://dartbug.com/34297 is fixed + const AndroidView({ Key key, @required this.viewType, this.onPlatformViewCreated, diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index 4225732c0d..5791c036b6 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -50,8 +50,7 @@ abstract class ScrollView extends StatelessWidget { /// Creates a widget that scrolls. /// /// If the [primary] argument is true, the [controller] must be null. - ScrollView({ // ignore: prefer_const_constructors_in_immutables - // TODO(aam): Remove lint ignore above once dartbug.com/34297 is fixed + const ScrollView({ Key key, this.scrollDirection = Axis.vertical, this.reverse = false, @@ -67,8 +66,8 @@ abstract class ScrollView extends StatelessWidget { 'Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. ' 'You cannot both set primary to true and pass an explicit controller.' ), - primary = primary ?? controller == null && scrollDirection == Axis.vertical, - physics = physics ?? (primary == true || (primary == null && controller == null && scrollDirection == Axis.vertical) ? const AlwaysScrollableScrollPhysics() : null), + primary = primary ?? controller == null && identical(scrollDirection, Axis.vertical), + physics = physics ?? (primary == true || (primary == null && controller == null && identical(scrollDirection, Axis.vertical)) ? const AlwaysScrollableScrollPhysics() : null), super(key: key); /// The axis along which the scroll view scrolls. @@ -386,7 +385,7 @@ class CustomScrollView extends ScrollView { /// Creates a [ScrollView] that creates custom scroll effects using slivers. /// /// If the [primary] argument is true, the [controller] must be null. - CustomScrollView({ + const CustomScrollView({ Key key, Axis scrollDirection = Axis.vertical, bool reverse = false, @@ -428,7 +427,7 @@ abstract class BoxScrollView extends ScrollView { /// Creates a [ScrollView] uses a single child layout model. /// /// If the [primary] argument is true, the [controller] must be null. - BoxScrollView({ + const BoxScrollView({ Key key, Axis scrollDirection = Axis.vertical, bool reverse = false, @@ -912,7 +911,7 @@ class ListView extends BoxScrollView { /// /// For example, a custom child model can control the algorithm used to /// estimate the size of children that are not actually visible. - ListView.custom({ + const ListView.custom({ Key key, Axis scrollDirection = Axis.vertical, bool reverse = false, @@ -1219,7 +1218,7 @@ class GridView extends BoxScrollView { /// a [SliverChildBuilderDelegate] or use the [GridView.builder] constructor. /// /// The [gridDelegate] and [childrenDelegate] arguments must not be null. - GridView.custom({ + const GridView.custom({ Key key, Axis scrollDirection = Axis.vertical, bool reverse = false, diff --git a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart index 5a9aa14c4d..e7e6932c40 100644 --- a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart @@ -183,8 +183,7 @@ import 'scrollable.dart'; /// * [Scrollable], which handles arbitrary scrolling effects. class SingleChildScrollView extends StatelessWidget { /// Creates a box in which a single widget can be scrolled. - SingleChildScrollView({ // ignore: prefer_const_constructors_in_immutables - // TODO(aam): Remove lint ignore above once dartbug.com/34297 is fixed + const SingleChildScrollView({ Key key, this.scrollDirection = Axis.vertical, this.reverse = false, @@ -198,7 +197,7 @@ class SingleChildScrollView extends StatelessWidget { 'Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. ' 'You cannot both set primary to true and pass an explicit controller.' ), - primary = primary ?? controller == null && scrollDirection == Axis.vertical, + primary = primary ?? controller == null && identical(scrollDirection, Axis.vertical), super(key: key); /// The axis along which the scroll view scrolls. diff --git a/packages/flutter/test/cupertino/nav_bar_test.dart b/packages/flutter/test/cupertino/nav_bar_test.dart index 0855c7ed5e..5303f94e7c 100644 --- a/packages/flutter/test/cupertino/nav_bar_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_test.dart @@ -602,10 +602,10 @@ void main() { 'Border is displayed by default in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( - CupertinoApp( + const CupertinoApp( home: CupertinoPageScaffold( child: CustomScrollView( - slivers: const [ + slivers: [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), ), @@ -632,10 +632,10 @@ void main() { 'Border is not displayed when null in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( - CupertinoApp( + const CupertinoApp( home: CupertinoPageScaffold( child: CustomScrollView( - slivers: const [ + slivers: [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), border: null, @@ -659,10 +659,10 @@ void main() { testWidgets('CupertinoSliverNavigationBar has semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(CupertinoApp( + await tester.pumpWidget(const CupertinoApp( home: CupertinoPageScaffold( child: CustomScrollView( - slivers: const [ + slivers: [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), border: null, @@ -706,10 +706,10 @@ void main() { 'Border can be overridden in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( - CupertinoApp( + const CupertinoApp( home: CupertinoPageScaffold( child: CustomScrollView( - slivers: const [ + slivers: [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), border: Border( diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index fd706fc382..3954464500 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -48,9 +48,9 @@ void main() { CupertinoPageRoute( title: 'An iPod', builder: (BuildContext context) { - return CupertinoPageScaffold( + return const CupertinoPageScaffold( child: CustomScrollView( - slivers: const [ + slivers: [ CupertinoSliverNavigationBar(), ], ), diff --git a/packages/flutter/test/cupertino/scrollbar_paint_test.dart b/packages/flutter/test/cupertino/scrollbar_paint_test.dart index 6b31a341c8..424f40fb2d 100644 --- a/packages/flutter/test/cupertino/scrollbar_paint_test.dart +++ b/packages/flutter/test/cupertino/scrollbar_paint_test.dart @@ -9,11 +9,11 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Paints iOS spec', (WidgetTester tester) async { - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: CupertinoScrollbar( child: SingleChildScrollView( - child: const SizedBox(width: 4000.0, height: 4000.0), + child: SizedBox(width: 4000.0, height: 4000.0), ), ), )); diff --git a/packages/flutter/test/cupertino/scrollbar_test.dart b/packages/flutter/test/cupertino/scrollbar_test.dart index 2350b823ef..de7d25eb88 100644 --- a/packages/flutter/test/cupertino/scrollbar_test.dart +++ b/packages/flutter/test/cupertino/scrollbar_test.dart @@ -9,11 +9,11 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Scrollbar never goes away until finger lift', (WidgetTester tester) async { - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: CupertinoScrollbar( child: SingleChildScrollView( - child: const SizedBox(width: 4000.0, height: 4000.0), + child: SizedBox(width: 4000.0, height: 4000.0), ), ), )); @@ -45,11 +45,11 @@ void main() { testWidgets('Scrollbar is not smaller than minLength with large scroll views', (WidgetTester tester) async { - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: CupertinoScrollbar( child: SingleChildScrollView( - child: const SizedBox(width: 800.0, height: 20000.0), + child: SizedBox(width: 800.0, height: 20000.0), ), ), )); diff --git a/packages/flutter/test/material/mergeable_material_test.dart b/packages/flutter/test/material/mergeable_material_test.dart index f671a5a2d2..b36622d494 100644 --- a/packages/flutter/test/material/mergeable_material_test.dart +++ b/packages/flutter/test/material/mergeable_material_test.dart @@ -67,10 +67,10 @@ BorderRadius getBorderRadius(WidgetTester tester, int index) { void main() { testWidgets('MergeableMaterial empty', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial() + child: MergeableMaterial() ), ), ), @@ -82,10 +82,10 @@ void main() { testWidgets('MergeableMaterial update slice', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -105,10 +105,10 @@ void main() { expect(box.size.height, equals(100.0)); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -130,10 +130,10 @@ void main() { testWidgets('MergeableMaterial swap slices', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -162,10 +162,10 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('B'), @@ -200,10 +200,10 @@ void main() { testWidgets('MergeableMaterial paints shadows', (WidgetTester tester) async { debugDisableShadows = false; await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -232,10 +232,10 @@ void main() { testWidgets('MergeableMaterial merge gap', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -268,10 +268,10 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -309,10 +309,10 @@ void main() { testWidgets('MergeableMaterial separate slices', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -341,10 +341,10 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -385,10 +385,10 @@ void main() { testWidgets('MergeableMaterial separate merge separate', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -417,10 +417,10 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -459,10 +459,10 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -498,10 +498,10 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Sharp, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -542,10 +542,10 @@ void main() { testWidgets('MergeableMaterial insert slice', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -574,10 +574,10 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -614,10 +614,10 @@ void main() { testWidgets('MergeableMaterial remove slice', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -653,10 +653,10 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -687,10 +687,10 @@ void main() { testWidgets('MergeableMaterial insert chunk', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -719,10 +719,10 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -775,10 +775,10 @@ void main() { testWidgets('MergeableMaterial remove chunk', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -822,10 +822,10 @@ void main() { matches(getBorderRadius(tester, 2), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -863,10 +863,10 @@ void main() { testWidgets('MergeableMaterial replace gap with chunk', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -899,10 +899,10 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -955,10 +955,10 @@ void main() { testWidgets('MergeableMaterial replace chunk with gap', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -1002,10 +1002,10 @@ void main() { matches(getBorderRadius(tester, 2), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( children: [ MaterialSlice( key: ValueKey('A'), @@ -1058,10 +1058,10 @@ void main() { testWidgets('MergeableMaterial dividers', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( hasDividers: true, children: [ MaterialSlice( @@ -1108,10 +1108,10 @@ void main() { expect(isDivider(boxes[offset + 3], true, false), isTrue); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: SingleChildScrollView( - child: const MergeableMaterial( + child: MergeableMaterial( hasDividers: true, children: [ MaterialSlice( diff --git a/packages/flutter/test/material/scrollbar_paint_test.dart b/packages/flutter/test/material/scrollbar_paint_test.dart index 39426b642d..56ced08df3 100644 --- a/packages/flutter/test/material/scrollbar_paint_test.dart +++ b/packages/flutter/test/material/scrollbar_paint_test.dart @@ -9,11 +9,11 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Viewport basic test (LTR)', (WidgetTester tester) async { - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: Scrollbar( child: SingleChildScrollView( - child: const SizedBox(width: 4000.0, height: 4000.0), + child: SizedBox(width: 4000.0, height: 4000.0), ), ), )); @@ -23,11 +23,11 @@ void main() { }); testWidgets('Viewport basic test (RTL)', (WidgetTester tester) async { - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.rtl, child: Scrollbar( child: SingleChildScrollView( - child: const SizedBox(width: 4000.0, height: 4000.0), + child: SizedBox(width: 4000.0, height: 4000.0), ), ), )); diff --git a/packages/flutter/test/material/scrollbar_test.dart b/packages/flutter/test/material/scrollbar_test.dart index 7fc7469c7c..a608643ce5 100644 --- a/packages/flutter/test/material/scrollbar_test.dart +++ b/packages/flutter/test/material/scrollbar_test.dart @@ -113,9 +113,9 @@ void main() { data: ThemeData( platform: platform ), - child: Scrollbar( + child: const Scrollbar( child: SingleChildScrollView( - child: const SizedBox(width: 4000.0, height: 4000.0), + child: SizedBox(width: 4000.0, height: 4000.0), ), ), ), diff --git a/packages/flutter/test/widgets/overscroll_indicator_test.dart b/packages/flutter/test/widgets/overscroll_indicator_test.dart index 0857b6e7eb..794f7f975e 100644 --- a/packages/flutter/test/widgets/overscroll_indicator_test.dart +++ b/packages/flutter/test/widgets/overscroll_indicator_test.dart @@ -24,10 +24,10 @@ Future slowDrag(WidgetTester tester, Offset start, Offset offset) async { void main() { testWidgets('Overscroll indicator color', (WidgetTester tester) async { await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: CustomScrollView( - slivers: const [ + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], ), @@ -70,8 +70,8 @@ void main() { scrollDirection: Axis.horizontal, child: Container( width: 600.0, - child: CustomScrollView( - slivers: const [ + child: const CustomScrollView( + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], ), @@ -91,10 +91,10 @@ void main() { testWidgets('Overscroll indicator changes side when you drag on the other side', (WidgetTester tester) async { await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: CustomScrollView( - slivers: const [ + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], ), @@ -129,10 +129,10 @@ void main() { testWidgets('Overscroll indicator changes side when you shift sides', (WidgetTester tester) async { await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: CustomScrollView( - slivers: const [ + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], ), @@ -165,11 +165,11 @@ void main() { group('Flipping direction of scrollable doesn\'t change overscroll behavior', () { testWidgets('down', (WidgetTester tester) async { await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: CustomScrollView( - physics: const AlwaysScrollableScrollPhysics(), - slivers: const [ + physics: AlwaysScrollableScrollPhysics(), + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), ], ), @@ -185,12 +185,12 @@ void main() { testWidgets('up', (WidgetTester tester) async { await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: CustomScrollView( reverse: true, - physics: const AlwaysScrollableScrollPhysics(), - slivers: const [ + physics: AlwaysScrollableScrollPhysics(), + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), ], ), @@ -207,11 +207,11 @@ void main() { testWidgets('Overscroll in both directions', (WidgetTester tester) async { await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: CustomScrollView( - physics: const AlwaysScrollableScrollPhysics(), - slivers: const [ + physics: AlwaysScrollableScrollPhysics(), + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), ], ), @@ -230,12 +230,12 @@ void main() { testWidgets('Overscroll horizontally', (WidgetTester tester) async { await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: CustomScrollView( scrollDirection: Axis.horizontal, - physics: const AlwaysScrollableScrollPhysics(), - slivers: const [ + physics: AlwaysScrollableScrollPhysics(), + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), ], ), @@ -283,11 +283,11 @@ void main() { textDirection: TextDirection.ltr, child: ScrollConfiguration( behavior: TestScrollBehavior1(), - child: CustomScrollView( + child: const CustomScrollView( scrollDirection: Axis.horizontal, - physics: const AlwaysScrollableScrollPhysics(), + physics: AlwaysScrollableScrollPhysics(), reverse: true, - slivers: const [ + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), ], ), @@ -305,10 +305,10 @@ void main() { textDirection: TextDirection.ltr, child: ScrollConfiguration( behavior: TestScrollBehavior2(), - child: CustomScrollView( + child: const CustomScrollView( scrollDirection: Axis.horizontal, - physics: const AlwaysScrollableScrollPhysics(), - slivers: const [ + physics: AlwaysScrollableScrollPhysics(), + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), ], ), diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index 5a0153f6be..a0daa0f607 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -23,7 +23,7 @@ void main() { viewsController.registerViewType('webview'); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -47,7 +47,7 @@ void main() { viewsController.registerViewType('webview'); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -55,7 +55,7 @@ void main() { viewType: 'webview', layoutDirection: TextDirection.ltr, creationParams: 'creation parameters', - creationParamsCodec: const StringCodec(), + creationParamsCodec: StringCodec(), ), ), ), @@ -85,7 +85,7 @@ void main() { viewsController.registerViewType('webview'); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 0.0, height: 0.0, @@ -105,7 +105,7 @@ void main() { final FakeAndroidPlatformViewsController viewsController = FakeAndroidPlatformViewsController(); viewsController.registerViewType('webview'); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -117,7 +117,7 @@ void main() { viewsController.resizeCompleter = Completer(); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 100.0, height: 50.0, @@ -156,7 +156,7 @@ void main() { viewsController.registerViewType('webview'); viewsController.registerViewType('maps'); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -166,7 +166,7 @@ void main() { ); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -188,7 +188,7 @@ void main() { final FakeAndroidPlatformViewsController viewsController = FakeAndroidPlatformViewsController(); viewsController.registerViewType('webview'); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -253,7 +253,7 @@ void main() { final FakeAndroidPlatformViewsController viewsController = FakeAndroidPlatformViewsController(); viewsController.registerViewType('webview'); await tester.pumpWidget( - Align( + const Align( alignment: Alignment.topLeft, child: SizedBox( width: 200.0, @@ -294,7 +294,7 @@ void main() { numPointerDownsOnParent++; }, ), - Positioned( + const Positioned( child: SizedBox( width: 200.0, height: 100.0, @@ -339,7 +339,7 @@ void main() { numPointerDownsOnParent++; }, ), - Positioned( + const Positioned( child: SizedBox( width: 200.0, height: 100.0, @@ -387,7 +387,7 @@ void main() { numPointerDownsOnParent++; }, ), - Positioned( + const Positioned( child: SizedBox( width: 200.0, height: 100.0, @@ -428,7 +428,7 @@ void main() { alignment: Alignment.topLeft, child: Container( margin: const EdgeInsets.all(10.0), - child: SizedBox( + child: const SizedBox( width: 200.0, height: 100.0, child: AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr), @@ -456,7 +456,7 @@ void main() { final FakeAndroidPlatformViewsController viewsController = FakeAndroidPlatformViewsController(); viewsController.registerViewType('maps'); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -474,7 +474,7 @@ void main() { ); await tester.pumpWidget( - Center( + const Center( child: SizedBox( width: 200.0, height: 100.0, @@ -497,7 +497,7 @@ void main() { final FakeAndroidPlatformViewsController viewsController = FakeAndroidPlatformViewsController(); viewsController.registerViewType('maps'); await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.rtl, child: Center( child: SizedBox( @@ -518,7 +518,7 @@ void main() { ); await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: Center( child: SizedBox( @@ -553,7 +553,7 @@ void main() { onVerticalDragStart: (DragStartDetails d) { verticalDragAcceptedByParent = true; }, - child: SizedBox( + child: const SizedBox( width: 200.0, height: 100.0, child: AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr), @@ -637,7 +637,7 @@ void main() { verticalDragAcceptedByParent = true; }, onLongPress: () {}, - child: SizedBox( + child: const SizedBox( width: 200.0, height: 100.0, child: AndroidView( @@ -669,7 +669,7 @@ void main() { final FakeAndroidPlatformViewsController viewsController = FakeAndroidPlatformViewsController(); viewsController.registerViewType('webview'); await tester.pumpWidget( - Align( + const Align( alignment: Alignment.topLeft, child: SizedBox( width: 200.0, @@ -686,7 +686,7 @@ void main() { await gesture.moveBy(const Offset(0.0, 100.0)); await tester.pumpWidget( - Align( + const Align( alignment: Alignment.topLeft, child: SizedBox( width: 200.0, diff --git a/packages/flutter/test/widgets/scroll_notification_test.dart b/packages/flutter/test/widgets/scroll_notification_test.dart index 5d7aedfe18..0fbadfad88 100644 --- a/packages/flutter/test/widgets/scroll_notification_test.dart +++ b/packages/flutter/test/widgets/scroll_notification_test.dart @@ -16,8 +16,8 @@ void main() { notification = value; return false; }, - child: SingleChildScrollView( - child: const SizedBox(height: 1200.0) + child: const SingleChildScrollView( + child: SizedBox(height: 1200.0) ) )); @@ -70,7 +70,7 @@ void main() { }, child: Container( padding: const EdgeInsets.all(50.0), - child: SingleChildScrollView(child: const SizedBox(height: 1200.0)) + child: const SingleChildScrollView(child: SizedBox(height: 1200.0)) ) ) ) diff --git a/packages/flutter/test/widgets/scroll_view_test.dart b/packages/flutter/test/widgets/scroll_view_test.dart index 5df19046f2..fc50e965d6 100644 --- a/packages/flutter/test/widgets/scroll_view_test.dart +++ b/packages/flutter/test/widgets/scroll_view_test.dart @@ -182,7 +182,7 @@ void main() { }); testWidgets('Vertical CustomScrollViews are primary by default', (WidgetTester tester) async { - final CustomScrollView view = CustomScrollView(scrollDirection: Axis.vertical); + const CustomScrollView view = CustomScrollView(scrollDirection: Axis.vertical); expect(view.primary, isTrue); }); @@ -200,7 +200,7 @@ void main() { }); testWidgets('Horizontal CustomScrollViews are non-primary by default', (WidgetTester tester) async { - final CustomScrollView view = CustomScrollView(scrollDirection: Axis.horizontal); + const CustomScrollView view = CustomScrollView(scrollDirection: Axis.horizontal); expect(view.primary, isFalse); }); @@ -249,7 +249,7 @@ void main() { textDirection: TextDirection.ltr, child: PrimaryScrollController( controller: primaryScrollController, - child: CustomScrollView(primary: true), + child: const CustomScrollView(primary: true), ), ), ); diff --git a/packages/flutter/test/widgets/scrollable_test.dart b/packages/flutter/test/widgets/scrollable_test.dart index 36fce7ce6f..66f99cc0bd 100644 --- a/packages/flutter/test/widgets/scrollable_test.dart +++ b/packages/flutter/test/widgets/scrollable_test.dart @@ -11,8 +11,8 @@ Future pumpTest(WidgetTester tester, TargetPlatform platform) async { theme: ThemeData( platform: platform, ), - home: CustomScrollView( - slivers: const [ + home: const CustomScrollView( + slivers: [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], ), diff --git a/packages/flutter/test/widgets/single_child_scroll_view_test.dart b/packages/flutter/test/widgets/single_child_scroll_view_test.dart index 4026b6ae75..6c86c43e0b 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -131,12 +131,12 @@ void main() { }); testWidgets('Vertical SingleChildScrollViews are primary by default', (WidgetTester tester) async { - final SingleChildScrollView view = SingleChildScrollView(scrollDirection: Axis.vertical); + const SingleChildScrollView view = SingleChildScrollView(scrollDirection: Axis.vertical); expect(view.primary, isTrue); }); testWidgets('Horizontal SingleChildScrollViews are non-primary by default', (WidgetTester tester) async { - final SingleChildScrollView view = SingleChildScrollView(scrollDirection: Axis.horizontal); + const SingleChildScrollView view = SingleChildScrollView(scrollDirection: Axis.horizontal); expect(view.primary, isFalse); });