From 7ceed9730292ea74528538c9654236d9f227ef44 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Fri, 10 Apr 2020 22:32:40 +0200 Subject: [PATCH] replace simple empty Container with w & h with SizedBox (#54394) * replace simple Container(w & h) with SizedBox * address review comments * address review comments --- .../lib/src/cupertino/action_sheet.dart | 2 +- .../lib/src/cupertino/context_menu.dart | 2 +- .../flutter/lib/src/cupertino/dialog.dart | 2 +- .../flutter/lib/src/material/data_table.dart | 2 +- .../lib/src/material/text_selection.dart | 2 +- .../flutter/test/cupertino/scaffold_test.dart | 4 +- .../test/cupertino/text_field_test.dart | 8 +-- .../test/material/text_field_test.dart | 6 +- .../flutter/test/material/tooltip_test.dart | 26 ++++---- .../test/material/tooltip_theme_test.dart | 40 ++++++------ packages/flutter/test/widgets/align_test.dart | 34 +++++----- .../test/widgets/box_decoration_test.dart | 2 +- .../flutter/test/widgets/column_test.dart | 24 +++---- .../widgets/composited_transform_test.dart | 2 +- .../custom_multi_child_layout_test.dart | 10 +-- .../test/widgets/custom_paint_test.dart | 2 +- .../flutter/test/widgets/drawer_test.dart | 2 +- .../test/widgets/ensure_visible_test.dart | 2 +- packages/flutter/test/widgets/flow_test.dart | 10 +-- .../test/widgets/focus_traversal_test.dart | 64 +++++++++---------- .../flutter/test/widgets/heroes_test.dart | 18 +++--- .../test/widgets/implicit_semantics_test.dart | 6 +- .../flutter/test/widgets/list_body_test.dart | 12 ++-- .../widgets/listener_deprecated_test.dart | 16 ++--- .../test/widgets/mouse_region_test.dart | 38 +++++------ .../test/widgets/reparent_state_test.dart | 22 +++---- .../test/widgets/scroll_events_test.dart | 4 +- .../flutter/test/widgets/semantics_test.dart | 4 +- .../test/widgets/shader_mask_test.dart | 6 +- .../test/widgets/simple_semantics_test.dart | 2 +- .../single_child_scroll_view_test.dart | 5 +- packages/flutter/test/widgets/stack_test.dart | 12 ++-- 32 files changed, 196 insertions(+), 195 deletions(-) diff --git a/packages/flutter/lib/src/cupertino/action_sheet.dart b/packages/flutter/lib/src/cupertino/action_sheet.dart index 93c4a29b47..bb57b25ed8 100644 --- a/packages/flutter/lib/src/cupertino/action_sheet.dart +++ b/packages/flutter/lib/src/cupertino/action_sheet.dart @@ -834,7 +834,7 @@ class _CupertinoAlertContentSection extends StatelessWidget { if (titleContentGroup.isEmpty) { return SingleChildScrollView( controller: scrollController, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), diff --git a/packages/flutter/lib/src/cupertino/context_menu.dart b/packages/flutter/lib/src/cupertino/context_menu.dart index de591b18bb..68d462e3d7 100644 --- a/packages/flutter/lib/src/cupertino/context_menu.dart +++ b/packages/flutter/lib/src/cupertino/context_menu.dart @@ -1036,7 +1036,7 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T ), ), ); - final Container spacer = Container( + const SizedBox spacer = SizedBox( width: _kPadding, height: _kPadding, ); diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index 79c6b7fd46..3623fc0cab 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -867,7 +867,7 @@ class _CupertinoAlertContentSection extends StatelessWidget { if (title == null && content == null) { return SingleChildScrollView( controller: scrollController, - child: Container(width: 0.0, height: 0.0), + child: const SizedBox(width: 0.0, height: 0.0), ); } diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 7d54c354fa..89b031c032 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -175,7 +175,7 @@ class DataCell { }) : assert(child != null); /// A cell that has no content and has zero width and height. - static final DataCell empty = DataCell(Container(width: 0.0, height: 0.0)); + static const DataCell empty = DataCell(SizedBox(width: 0.0, height: 0.0)); /// The data for the row. /// diff --git a/packages/flutter/lib/src/material/text_selection.dart b/packages/flutter/lib/src/material/text_selection.dart index 8ad2fd1a7b..a521112154 100644 --- a/packages/flutter/lib/src/material/text_selection.dart +++ b/packages/flutter/lib/src/material/text_selection.dart @@ -100,7 +100,7 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke // If there is no option available, build an empty widget. if (items.isEmpty) { - return Container(width: 0.0, height: 0.0); + return const SizedBox(width: 0.0, height: 0.0); } diff --git a/packages/flutter/test/cupertino/scaffold_test.dart b/packages/flutter/test/cupertino/scaffold_test.dart index e73434cc6c..07aef20fb6 100644 --- a/packages/flutter/test/cupertino/scaffold_test.dart +++ b/packages/flutter/test/cupertino/scaffold_test.dart @@ -236,7 +236,7 @@ void main() { }); testWidgets('Contents have automatic sliver padding between translucent bars', (WidgetTester tester) async { - final Container content = Container(height: 600.0, width: 600.0); + const SizedBox content = SizedBox(height: 600.0, width: 600.0); await tester.pumpWidget( CupertinoApp( @@ -264,7 +264,7 @@ void main() { middle: Text('Title'), ), child: ListView( - children: [ + children: const [ content, ], ), diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index e472c6814c..49fb244ea8 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -3623,7 +3623,7 @@ void main() { focusNode: focusNode, expands: true, maxLines: null, - prefix: Container( + prefix: const SizedBox( height: 100, width: 10, ), @@ -3676,7 +3676,7 @@ void main() { focusNode: focusNode, expands: true, maxLines: null, - prefix: Container( + prefix: const SizedBox( height: 100, width: 10, ), @@ -3730,7 +3730,7 @@ void main() { focusNode: focusNode, expands: true, maxLines: null, - prefix: Container( + prefix: const SizedBox( height: 100, width: 10, ), @@ -3784,7 +3784,7 @@ void main() { focusNode: focusNode, expands: true, maxLines: null, - prefix: Container( + prefix: const SizedBox( height: 100, width: 10, ), diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 34590ec6bb..1b063254a1 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -1084,8 +1084,8 @@ void main() { await tester.pumpAndSettle(); final RenderBox container = tester.renderObject(find.descendant( of: find.byType(FadeTransition), - matching: find.byType(Container), - )); + matching: find.byType(SizedBox), + ).first); expect(container.size, Size.zero); }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); @@ -2252,7 +2252,7 @@ void main() { await tester.pumpWidget(containedTextFieldBuilder( counter: Container(height: counterHeight), labelText: 'I am labelText', - prefix: Container( + prefix: const SizedBox( width: 10, height: 60, ), diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index 5e28e5ed1b..24da03de4f 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -61,7 +61,7 @@ void main() { padding: const EdgeInsets.all(5.0), verticalOffset: 20.0, preferBelow: false, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -118,7 +118,7 @@ void main() { padding: const EdgeInsets.all(5.0), verticalOffset: 20.0, preferBelow: false, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -172,7 +172,7 @@ void main() { padding: const EdgeInsets.all(0.0), verticalOffset: 100.0, preferBelow: false, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -228,7 +228,7 @@ void main() { padding: const EdgeInsets.all(0.0), verticalOffset: 100.0, preferBelow: false, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -295,7 +295,7 @@ void main() { padding: const EdgeInsets.all(0.0), verticalOffset: 100.0, preferBelow: true, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -350,7 +350,7 @@ void main() { padding: const EdgeInsets.all(0.0), verticalOffset: 10.0, preferBelow: true, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -407,7 +407,7 @@ void main() { padding: const EdgeInsets.all(0.0), verticalOffset: 10.0, preferBelow: true, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -458,7 +458,7 @@ void main() { message: tooltipText, padding: const EdgeInsets.all(0.0), margin: const EdgeInsets.all(_customMarginValue), - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -654,7 +654,7 @@ void main() { return Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -696,7 +696,7 @@ void main() { key: key, decoration: customDecoration, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -780,12 +780,12 @@ void main() { await gesture.moveTo(Offset.zero); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Center( child: Tooltip( message: tooltipText, waitDuration: waitDuration, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, ), @@ -838,7 +838,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container(width: 10.0, height: 10.0), + child: const SizedBox(width: 10.0, height: 10.0), ), ), ], diff --git a/packages/flutter/test/material/tooltip_theme_test.dart b/packages/flutter/test/material/tooltip_theme_test.dart index 88b94786cd..0be8543986 100644 --- a/packages/flutter/test/material/tooltip_theme_test.dart +++ b/packages/flutter/test/material/tooltip_theme_test.dart @@ -119,7 +119,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -177,7 +177,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -237,7 +237,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -306,7 +306,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -377,7 +377,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -434,7 +434,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -486,7 +486,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -542,7 +542,7 @@ void main() { child: Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -662,7 +662,7 @@ void main() { return Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -704,7 +704,7 @@ void main() { return Tooltip( key: key, message: tooltipText, - child: Container( + child: const SizedBox( width: 0.0, height: 0.0, ), @@ -837,10 +837,10 @@ void main() { waitDuration: customWaitDuration, ), ), - child: Center( + child: const Center( child: Tooltip( message: tooltipText, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, ), @@ -878,13 +878,13 @@ void main() { await gesture.moveTo(Offset.zero); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: TooltipTheme( - data: const TooltipThemeData(waitDuration: customWaitDuration), + data: TooltipThemeData(waitDuration: customWaitDuration), child: Center( child: Tooltip( message: tooltipText, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, ), @@ -922,10 +922,10 @@ void main() { showDuration: customShowDuration, ), ), - child: Center( + child: const Center( child: Tooltip( message: tooltipText, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, ), @@ -952,13 +952,13 @@ void main() { testWidgets('Tooltip showDuration - TooltipTheme', (WidgetTester tester) async { const Duration customShowDuration = Duration(milliseconds: 3000); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: TooltipTheme( - data: const TooltipThemeData(showDuration: customShowDuration), + data: TooltipThemeData(showDuration: customShowDuration), child: Center( child: Tooltip( message: tooltipText, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, ), diff --git a/packages/flutter/test/widgets/align_test.dart b/packages/flutter/test/widgets/align_test.dart index bc0db9737d..61ffbe3283 100644 --- a/packages/flutter/test/widgets/align_test.dart +++ b/packages/flutter/test/widgets/align_test.dart @@ -44,51 +44,51 @@ void main() { }); testWidgets('Align control test (LTR)', (WidgetTester tester) async { - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: Align( - child: Container(width: 100.0, height: 80.0), + child: SizedBox(width: 100.0, height: 80.0), alignment: AlignmentDirectional.topStart, ), )); - expect(tester.getTopLeft(find.byType(Container)).dx, 0.0); - expect(tester.getBottomRight(find.byType(Container)).dx, 100.0); + expect(tester.getTopLeft(find.byType(SizedBox)).dx, 0.0); + expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0); - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: Align( - child: Container(width: 100.0, height: 80.0), + child: SizedBox(width: 100.0, height: 80.0), alignment: Alignment.topLeft, ), )); - expect(tester.getTopLeft(find.byType(Container)).dx, 0.0); - expect(tester.getBottomRight(find.byType(Container)).dx, 100.0); + expect(tester.getTopLeft(find.byType(SizedBox)).dx, 0.0); + expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0); }); testWidgets('Align control test (RTL)', (WidgetTester tester) async { - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.rtl, child: Align( - child: Container(width: 100.0, height: 80.0), + child: SizedBox(width: 100.0, height: 80.0), alignment: AlignmentDirectional.topStart, ), )); - expect(tester.getTopLeft(find.byType(Container)).dx, 700.0); - expect(tester.getBottomRight(find.byType(Container)).dx, 800.0); + expect(tester.getTopLeft(find.byType(SizedBox)).dx, 700.0); + expect(tester.getBottomRight(find.byType(SizedBox)).dx, 800.0); - await tester.pumpWidget(Directionality( + await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: Align( - child: Container(width: 100.0, height: 80.0), + child: SizedBox(width: 100.0, height: 80.0), alignment: Alignment.topLeft, ), )); - expect(tester.getTopLeft(find.byType(Container)).dx, 0.0); - expect(tester.getBottomRight(find.byType(Container)).dx, 100.0); + expect(tester.getTopLeft(find.byType(SizedBox)).dx, 0.0); + expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0); }); testWidgets('Shrink wraps in finite space', (WidgetTester tester) async { @@ -97,7 +97,7 @@ void main() { SingleChildScrollView( child: Align( key: alignKey, - child: Container( + child: const SizedBox( width: 10.0, height: 10.0, ), diff --git a/packages/flutter/test/widgets/box_decoration_test.dart b/packages/flutter/test/widgets/box_decoration_test.dart index bf42da188a..0c410b4702 100644 --- a/packages/flutter/test/widgets/box_decoration_test.dart +++ b/packages/flutter/test/widgets/box_decoration_test.dart @@ -112,7 +112,7 @@ Future main() async { child: Container( key: key, decoration: BoxDecoration(border: Border.all(width: 10.0)), - child: Container( + child: const SizedBox( width: 25.0, height: 25.0, ), diff --git a/packages/flutter/test/widgets/column_test.dart b/packages/flutter/test/widgets/column_test.dart index 4d42fccbc3..ef957985c8 100644 --- a/packages/flutter/test/widgets/column_test.dart +++ b/packages/flutter/test/widgets/column_test.dart @@ -338,9 +338,9 @@ void main() { await tester.pumpWidget(Center( child: Column( key: flexKey, - children: [ - Container(width: 100.0, height: 100.0), - Container(width: 100.0, height: 150.0), + children: const [ + SizedBox(width: 100.0, height: 100.0), + SizedBox(width: 100.0, height: 150.0), ], ), )); @@ -353,9 +353,9 @@ void main() { child: Column( key: flexKey, mainAxisSize: MainAxisSize.min, - children: [ - Container(width: 100.0, height: 100.0), - Container(width: 100.0, height: 150.0), + children: const [ + SizedBox(width: 100.0, height: 100.0), + SizedBox(width: 100.0, height: 150.0), ], ), )); @@ -729,9 +729,9 @@ void main() { child: Column( key: flexKey, verticalDirection: VerticalDirection.up, - children: [ - Container(width: 100.0, height: 100.0), - Container(width: 100.0, height: 150.0), + children: const [ + SizedBox(width: 100.0, height: 100.0), + SizedBox(width: 100.0, height: 150.0), ], ), )); @@ -745,9 +745,9 @@ void main() { key: flexKey, mainAxisSize: MainAxisSize.min, verticalDirection: VerticalDirection.up, - children: [ - Container(width: 100.0, height: 100.0), - Container(width: 100.0, height: 150.0), + children: const [ + SizedBox(width: 100.0, height: 100.0), + SizedBox(width: 100.0, height: 150.0), ], ), )); diff --git a/packages/flutter/test/widgets/composited_transform_test.dart b/packages/flutter/test/widgets/composited_transform_test.dart index c1ce6b1e41..a6029a0c3f 100644 --- a/packages/flutter/test/widgets/composited_transform_test.dart +++ b/packages/flutter/test/widgets/composited_transform_test.dart @@ -20,7 +20,7 @@ void main() { top: 456.0, child: CompositedTransformTarget( link: link, - child: Container(height: 10.0, width: 10.0), + child: const SizedBox(height: 10.0, width: 10.0), ), ), Positioned( diff --git a/packages/flutter/test/widgets/custom_multi_child_layout_test.dart b/packages/flutter/test/widgets/custom_multi_child_layout_test.dart index c0fdc89524..ddd5c33409 100644 --- a/packages/flutter/test/widgets/custom_multi_child_layout_test.dart +++ b/packages/flutter/test/widgets/custom_multi_child_layout_test.dart @@ -49,8 +49,8 @@ Widget buildFrame(MultiChildLayoutDelegate delegate) { return Center( child: CustomMultiChildLayout( children: [ - LayoutId(id: 0, child: Container(width: 150.0, height: 100.0)), - LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)), + LayoutId(id: 0, child: const SizedBox(width: 150.0, height: 100.0)), + LayoutId(id: 1, child: const SizedBox(width: 100.0, height: 200.0)), ], delegate: delegate, ), @@ -225,13 +225,13 @@ void main() { id: 0, child: CustomMultiChildLayout( children: [ - LayoutId(id: 0, child: Container(width: 150.0, height: 100.0)), - LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)), + LayoutId(id: 0, child: const SizedBox(width: 150.0, height: 100.0)), + LayoutId(id: 1, child: const SizedBox(width: 100.0, height: 200.0)), ], delegate: delegate, ), ), - LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)), + LayoutId(id: 1, child: const SizedBox(width: 100.0, height: 200.0)), ], delegate: delegate, ), diff --git a/packages/flutter/test/widgets/custom_paint_test.dart b/packages/flutter/test/widgets/custom_paint_test.dart index e1c730f232..3162f00f92 100644 --- a/packages/flutter/test/widgets/custom_paint_test.dart +++ b/packages/flutter/test/widgets/custom_paint_test.dart @@ -195,7 +195,7 @@ void main() { expect(target.currentContext.size, const Size(800.0, 600.0)); await tester.pumpWidget(Center( - child: CustomPaint(key: target, child: Container(height: 0.0, width: 0.0)), + child: CustomPaint(key: target, child: const SizedBox(height: 0.0, width: 0.0)), )); expect(target.currentContext.size, Size.zero); diff --git a/packages/flutter/test/widgets/drawer_test.dart b/packages/flutter/test/widgets/drawer_test.dart index 4d9714081a..3a88519bd8 100644 --- a/packages/flutter/test/widgets/drawer_test.dart +++ b/packages/flutter/test/widgets/drawer_test.dart @@ -97,7 +97,7 @@ void main() { onEnter: (_) { logs.add('enter'); }, onHover: (_) { logs.add('hover'); }, onExit: (_) { logs.add('exit'); }, - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ), diff --git a/packages/flutter/test/widgets/ensure_visible_test.dart b/packages/flutter/test/widgets/ensure_visible_test.dart index daf90a4a9a..bb8a7029f2 100644 --- a/packages/flutter/test/widgets/ensure_visible_test.dart +++ b/packages/flutter/test/widgets/ensure_visible_test.dart @@ -384,7 +384,7 @@ void main() { Widget buildSliver(int i) { return SliverToBoxAdapter( key: ValueKey(i), - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ); } diff --git a/packages/flutter/test/widgets/flow_test.dart b/packages/flutter/test/widgets/flow_test.dart index 4386b15e79..eb21e28b64 100644 --- a/packages/flutter/test/widgets/flow_test.dart +++ b/packages/flutter/test/widgets/flow_test.dart @@ -119,9 +119,9 @@ void main() { await tester.pumpWidget( Flow( delegate: DuplicatePainterOpacityFlowDelegate(1.0), - children: [ - Container(width: 100.0, height: 100.0), - Container(width: 100.0, height: 100.0), + children: const [ + SizedBox(width: 100.0, height: 100.0), + SizedBox(width: 100.0, height: 100.0), ], ), ); @@ -142,8 +142,8 @@ void main() { await tester.pumpWidget( Flow( delegate: OpacityFlowDelegate(opacity), - children: [ - Container(width: 100.0, height: 100.0), + children: const [ + SizedBox(width: 100.0, height: 100.0), ], ), ); diff --git a/packages/flutter/test/widgets/focus_traversal_test.dart b/packages/flutter/test/widgets/focus_traversal_test.dart index 6517a68675..0f21857d65 100644 --- a/packages/flutter/test/widgets/focus_traversal_test.dart +++ b/packages/flutter/test/widgets/focus_traversal_test.dart @@ -559,15 +559,15 @@ void main() { child: Row(children: [ Focus( focusNode: nodes[0], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), Focus( focusNode: nodes[1], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), Focus( focusNode: nodes[2], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ]), ), @@ -578,21 +578,21 @@ void main() { textDirection: TextDirection.rtl, child: Focus( focusNode: nodes[3], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), Directionality( textDirection: TextDirection.rtl, child: Focus( focusNode: nodes[4], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), Directionality( textDirection: TextDirection.ltr, child: Focus( focusNode: nodes[5], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ]), @@ -602,28 +602,28 @@ void main() { textDirection: TextDirection.ltr, child: Focus( focusNode: nodes[6], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), Directionality( textDirection: TextDirection.rtl, child: Focus( focusNode: nodes[7], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), Directionality( textDirection: TextDirection.rtl, child: Focus( focusNode: nodes[8], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), Directionality( textDirection: TextDirection.ltr, child: Focus( focusNode: nodes[9], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ]), @@ -670,7 +670,7 @@ void main() { // Boxes that all have the same upper left origin corner. return Focus( focusNode: nodes[index], - child: Container(width: 10.0 * (index + 1), height: 10.0 * (index + 1)), + child: SizedBox(width: 10.0 * (index + 1), height: 10.0 * (index + 1)), ); }), ), @@ -697,7 +697,7 @@ void main() { children: List.generate(nodeCount, (int index) { return Focus( focusNode: nodes[index], - child: Container(width: 10.0 * (index + 1), height: 10.0 * (index + 1)), + child: SizedBox(width: 10.0 * (index + 1), height: 10.0 * (index + 1)), ); }), ), @@ -805,7 +805,7 @@ void main() { nodeCount, (int index) => Focus( focusNode: nodes[index], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ), @@ -846,7 +846,7 @@ void main() { order: NumericFocusOrder(nodeCount - index.toDouble()), child: Focus( focusNode: nodes[index], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ), @@ -890,7 +890,7 @@ void main() { order: LexicalFocusOrder(keys[index]), child: Focus( focusNode: nodes[index], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ), @@ -939,21 +939,21 @@ void main() { order: const NumericFocusOrder(9), child: Focus( focusNode: nodes[9], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), FocusTraversalOrder( order: const NumericFocusOrder(8), child: Focus( focusNode: nodes[8], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), FocusTraversalOrder( order: const NumericFocusOrder(7), child: Focus( focusNode: nodes[7], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ]), @@ -968,21 +968,21 @@ void main() { order: const NumericFocusOrder(4), child: Focus( focusNode: nodes[4], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), FocusTraversalOrder( order: const NumericFocusOrder(5), child: Focus( focusNode: nodes[5], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), FocusTraversalOrder( order: const NumericFocusOrder(6), child: Focus( focusNode: nodes[6], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ]), @@ -997,28 +997,28 @@ void main() { order: const LexicalFocusOrder('D'), child: Focus( focusNode: nodes[3], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), FocusTraversalOrder( order: const LexicalFocusOrder('C'), child: Focus( focusNode: nodes[2], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), FocusTraversalOrder( order: const LexicalFocusOrder('B'), child: Focus( focusNode: nodes[1], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), FocusTraversalOrder( order: const LexicalFocusOrder('A'), child: Focus( focusNode: nodes[0], - child: Container(width: 10, height: 10), + child: const SizedBox(width: 10, height: 10), ), ), ]), @@ -1426,9 +1426,9 @@ void main() { debugLabel: 'lowerLeft', child: Container(width: 100, height: 100, key: lowerLeftKey), ), - Focus( + const Focus( debugLabel: 'lowerRight', - child: Container(width: 100, height: 100), + child: SizedBox(width: 100, height: 100), ), ], ), @@ -1466,9 +1466,9 @@ void main() { debugLabel: 'Scope', child: Column( children: [ - Focus(focusNode: focusTop, child: Container(width: 100, height: 100)), - Focus(focusNode: focusCenter, child: Container(width: 100, height: 100)), - Focus(focusNode: focusBottom, child: Container(width: 100, height: 100)), + Focus(focusNode: focusTop, child: const SizedBox(width: 100, height: 100)), + Focus(focusNode: focusCenter, child: const SizedBox(width: 100, height: 100)), + Focus(focusNode: focusBottom, child: const SizedBox(width: 100, height: 100)), ], ), ), @@ -1490,8 +1490,8 @@ void main() { debugLabel: 'Scope', child: Column( children: [ - Focus(focusNode: focusTop, child: Container(width: 100, height: 100)), - Focus(focusNode: focusBottom, child: Container(width: 100, height: 100)), + Focus(focusNode: focusTop, child: const SizedBox(width: 100, height: 100)), + Focus(focusNode: focusBottom, child: const SizedBox(width: 100, height: 100)), ], ), ), diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index c6fc32a079..770e5746c7 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -40,13 +40,13 @@ final Map routes = { child: ListView( key: homeRouteKey, children: [ - Container(height: 100.0, width: 100.0), + const SizedBox(height: 100.0, width: 100.0), Card(child: Hero( tag: 'a', transitionOnUserGestures: transitionFromUserGestures, child: Container(height: 100.0, width: 100.0, key: firstKey), )), - Container(height: 100.0, width: 100.0), + const SizedBox(height: 100.0, width: 100.0), FlatButton( child: const Text('two'), onPressed: () { Navigator.pushNamed(context, '/two'); }, @@ -70,13 +70,13 @@ final Map routes = { child: const Text('pop'), onPressed: () { Navigator.pop(context); }, ), - Container(height: 150.0, width: 150.0), + const SizedBox(height: 150.0, width: 150.0), Card(child: Hero( tag: 'a', transitionOnUserGestures: transitionFromUserGestures, child: Container(height: 150.0, width: 150.0, key: secondKey), )), - Container(height: 150.0, width: 150.0), + const SizedBox(height: 150.0, width: 150.0), FlatButton( child: const Text('three'), onPressed: () { Navigator.push(context, ThreeRoute()); }, @@ -96,7 +96,7 @@ final Map routes = { child: const Text('pop'), onPressed: () { Navigator.pop(context); }, ), - Container(height: 150.0, width: 150.0), + const SizedBox(height: 150.0, width: 150.0), Card( child: Padding( padding: const EdgeInsets.only(left: 50.0), @@ -107,7 +107,7 @@ final Map routes = { ), ), ), - Container(height: 150.0, width: 150.0), + const SizedBox(height: 150.0, width: 150.0), FlatButton( child: const Text('three'), onPressed: () { Navigator.push(context, ThreeRoute()); }, @@ -137,9 +137,9 @@ class ThreeRoute extends MaterialPageRoute { key: routeThreeKey, child: ListView( children: [ - Container(height: 200.0, width: 200.0), + const SizedBox(height: 200.0, width: 200.0), Card(child: Hero(tag: 'a', child: Container(height: 200.0, width: 200.0, key: thirdKey))), - Container(height: 200.0, width: 200.0), + const SizedBox(height: 200.0, width: 200.0), ], ), ); @@ -718,7 +718,7 @@ Future main() async { return Card( child: routeIncludesHero ? Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0)) - : Container(height: 200.0, width: 200.0), + : const SizedBox(height: 200.0, width: 200.0), ); }, ), diff --git a/packages/flutter/test/widgets/implicit_semantics_test.dart b/packages/flutter/test/widgets/implicit_semantics_test.dart index 52b38fa076..a32dfcedc1 100644 --- a/packages/flutter/test/widgets/implicit_semantics_test.dart +++ b/packages/flutter/test/widgets/implicit_semantics_test.dart @@ -189,7 +189,7 @@ void main() { Semantics( label: 'node 1', selected: true, - child: Container( + child: const SizedBox( width: 10.0, height: 10.0, ), @@ -197,7 +197,7 @@ void main() { Semantics( label: 'node 2', selected: true, - child: Container( + child: const SizedBox( width: 10.0, height: 10.0, ), @@ -205,7 +205,7 @@ void main() { Semantics( label: 'node 3', selected: true, - child: Container( + child: const SizedBox( width: 10.0, height: 10.0, ), diff --git a/packages/flutter/test/widgets/list_body_test.dart b/packages/flutter/test/widgets/list_body_test.dart index 8d8ad942fc..e707e23080 100644 --- a/packages/flutter/test/widgets/list_body_test.dart +++ b/packages/flutter/test/widgets/list_body_test.dart @@ -7,15 +7,15 @@ import 'package:flutter/src/painting/basic_types.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; -final List children = [ - Container(width: 200.0, height: 150.0), - Container(width: 200.0, height: 150.0), - Container(width: 200.0, height: 150.0), - Container(width: 200.0, height: 150.0), +const List children = [ + SizedBox(width: 200.0, height: 150.0), + SizedBox(width: 200.0, height: 150.0), + SizedBox(width: 200.0, height: 150.0), + SizedBox(width: 200.0, height: 150.0), ]; void expectRects(WidgetTester tester, List expected) { - final Finder finder = find.byType(Container); + final Finder finder = find.byType(SizedBox); finder.precache(); final List actual = []; for (int i = 0; i < expected.length; ++i) { diff --git a/packages/flutter/test/widgets/listener_deprecated_test.dart b/packages/flutter/test/widgets/listener_deprecated_test.dart index 1f190f6c7e..5ce9249bd1 100644 --- a/packages/flutter/test/widgets/listener_deprecated_test.dart +++ b/packages/flutter/test/widgets/listener_deprecated_test.dart @@ -122,7 +122,7 @@ void main() { await tester.pumpWidget( Center( child: Listener( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -152,7 +152,7 @@ void main() { await tester.pumpWidget( Center( child: Listener( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -170,8 +170,8 @@ void main() { expect(enter, isNotNull); expect(enter.position, equals(const Offset(400.0, 300.0))); expect(exit, isNull); - await tester.pumpWidget(Center( - child: Container( + await tester.pumpWidget(const Center( + child: SizedBox( width: 100.0, height: 100.0, ), @@ -284,7 +284,7 @@ void main() { children: [ Listener( key: key1, - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -294,7 +294,7 @@ void main() { ), Listener( key: key2, - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -561,7 +561,7 @@ void main() { onPointerEnter: (PointerEnterEvent e) => enter.add(e), onPointerHover: (PointerHoverEvent e) => hover.add(e), onPointerExit: (PointerExitEvent e) => exit.add(e), - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -574,7 +574,7 @@ void main() { await gesture.addPointer(location: Offset.zero); addTearDown(() => gesture?.removePointer()); await tester.pumpAndSettle(); - await gesture.moveTo(tester.getCenter(find.byType(Container))); + await gesture.moveTo(tester.getCenter(find.byType(SizedBox))); expect(enter.length, 1); expect(enter.single.position, const Offset(400.0, 300.0)); diff --git a/packages/flutter/test/widgets/mouse_region_test.dart b/packages/flutter/test/widgets/mouse_region_test.dart index 25b3fc921d..867f7f1505 100644 --- a/packages/flutter/test/widgets/mouse_region_test.dart +++ b/packages/flutter/test/widgets/mouse_region_test.dart @@ -119,7 +119,7 @@ void main() { PointerExitEvent exit; await tester.pumpWidget(Center( child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -149,7 +149,7 @@ void main() { PointerExitEvent exit; await tester.pumpWidget(Center( child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -179,7 +179,7 @@ void main() { PointerExitEvent exit; await tester.pumpWidget(Center( child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -214,8 +214,8 @@ void main() { PointerEnterEvent enter; PointerHoverEvent move; PointerExitEvent exit; - await tester.pumpWidget(Center( - child: Container( + await tester.pumpWidget(const Center( + child: SizedBox( width: 100.0, height: 100.0, ), @@ -230,7 +230,7 @@ void main() { expect(exit, isNull); await tester.pumpWidget(Center( child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -252,7 +252,7 @@ void main() { PointerExitEvent exit; await tester.pumpWidget(Center( child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -269,8 +269,8 @@ void main() { move = null; enter = null; exit = null; - await tester.pumpWidget(Center( - child: Container( + await tester.pumpWidget(const Center( + child: SizedBox( width: 100.0, height: 100.0, ), @@ -287,7 +287,7 @@ void main() { await tester.pumpWidget(Container( alignment: Alignment.center, child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -306,7 +306,7 @@ void main() { await tester.pumpWidget(Container( alignment: Alignment.topLeft, child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -329,7 +329,7 @@ void main() { await tester.pumpWidget(Container( alignment: Alignment.center, child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -348,7 +348,7 @@ void main() { await tester.pumpWidget(Container( alignment: Alignment.topLeft, child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -471,7 +471,7 @@ void main() { children: [ MouseRegion( key: key1, - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -481,7 +481,7 @@ void main() { ), MouseRegion( key: key2, - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), @@ -842,7 +842,7 @@ void main() { onEnter: (PointerEnterEvent e) => enter.add(e), onHover: (PointerHoverEvent e) => hover.add(e), onExit: (PointerExitEvent e) => exit.add(e), - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -855,7 +855,7 @@ void main() { await gesture.addPointer(location: Offset.zero); addTearDown(() => gesture?.removePointer()); await tester.pumpAndSettle(); - await gesture.moveTo(tester.getCenter(find.byType(Container))); + await gesture.moveTo(tester.getCenter(find.byType(SizedBox))); expect(enter.length, 1); expect(enter.single.position, const Offset(400.0, 300.0)); @@ -1286,7 +1286,7 @@ void main() { onEnter: (_) { bottomRegionIsHovered = true; }, onHover: (_) { bottomRegionIsHovered = true; }, onExit: (_) { bottomRegionIsHovered = true; }, - child: Container( + child: const SizedBox( width: 10, height: 10, ), @@ -1456,7 +1456,7 @@ void main() { testWidgets('No new frames are scheduled when mouse moves without triggering callbacks', (WidgetTester tester) async { await tester.pumpWidget(Center( child: MouseRegion( - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, ), diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 95d56ade80..e31db61c70 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -231,7 +231,7 @@ void main() { textDirection: TextDirection.ltr, children: [ StateMarker(key: key), - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), ], )); @@ -241,7 +241,7 @@ void main() { await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), StateMarker(key: key), ], )); @@ -253,7 +253,7 @@ void main() { textDirection: TextDirection.ltr, children: [ StateMarker(key: key), - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), ], )); @@ -267,9 +267,9 @@ void main() { await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), StateMarker(key: key), - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), ], )); @@ -280,7 +280,7 @@ void main() { textDirection: TextDirection.ltr, children: [ Container(width: 100.0, height: 100.0, child: StateMarker(key: key)), - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), ], )); @@ -290,9 +290,9 @@ void main() { await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), StateMarker(key: key), - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), ], )); @@ -302,7 +302,7 @@ void main() { await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), Container(width: 100.0, height: 100.0, child: StateMarker(key: key)), ], )); @@ -313,9 +313,9 @@ void main() { await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), StateMarker(key: key), - Container(width: 100.0, height: 100.0), + const SizedBox(width: 100.0, height: 100.0), ], )); diff --git a/packages/flutter/test/widgets/scroll_events_test.dart b/packages/flutter/test/widgets/scroll_events_test.dart index 585e3df4b8..93c7785054 100644 --- a/packages/flutter/test/widgets/scroll_events_test.dart +++ b/packages/flutter/test/widgets/scroll_events_test.dart @@ -20,8 +20,8 @@ Widget _buildScroller({ List log }) { } return false; }, - child: SingleChildScrollView( - child: Container(width: 1000.0, height: 1000.0), + child: const SingleChildScrollView( + child: SizedBox(width: 1000.0, height: 1000.0), ), ); } diff --git a/packages/flutter/test/widgets/semantics_test.dart b/packages/flutter/test/widgets/semantics_test.dart index bc31ebed05..b4cff76877 100644 --- a/packages/flutter/test/widgets/semantics_test.dart +++ b/packages/flutter/test/widgets/semantics_test.dart @@ -312,14 +312,14 @@ void main() { children: [ Semantics( value: 'value one', - child: Container( + child: const SizedBox( height: 10.0, width: 10.0, ), ), Semantics( value: 'value two', - child: Container( + child: const SizedBox( height: 10.0, width: 10.0, ), diff --git a/packages/flutter/test/widgets/shader_mask_test.dart b/packages/flutter/test/widgets/shader_mask_test.dart index 17a5456e15..363475eab5 100644 --- a/packages/flutter/test/widgets/shader_mask_test.dart +++ b/packages/flutter/test/widgets/shader_mask_test.dart @@ -19,8 +19,8 @@ Shader createShader(Rect bounds) { void main() { testWidgets('Can be constructed', (WidgetTester tester) async { - final Widget child = Container(width: 100.0, height: 100.0); - await tester.pumpWidget(ShaderMask(child: child, shaderCallback: createShader)); + const Widget child = SizedBox(width: 100.0, height: 100.0); + await tester.pumpWidget(const ShaderMask(child: child, shaderCallback: createShader)); }, skip: isBrowser); testWidgets('Bounds rect includes offset', (WidgetTester tester) async { @@ -37,7 +37,7 @@ void main() { height: 400.0, child: ShaderMask( shaderCallback: recordShaderBounds, - child: Container(width: 100.0, height: 100.0), + child: const SizedBox(width: 100.0, height: 100.0), ), ), ); diff --git a/packages/flutter/test/widgets/simple_semantics_test.dart b/packages/flutter/test/widgets/simple_semantics_test.dart index 394812d0da..b9b2c4e38f 100644 --- a/packages/flutter/test/widgets/simple_semantics_test.dart +++ b/packages/flutter/test/widgets/simple_semantics_test.dart @@ -44,7 +44,7 @@ void main() { home: Center( child: Semantics( label: 'Hello!', - child: Container( + child: const SizedBox( width: 10.0, height: 10.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 8ba799cbc4..9f554ee6f3 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -581,8 +581,9 @@ void main() { children: List.generate(10, (int y) { return Row( children: children[y] = List.generate(10, (int x) { - return Container( - height: 100.0, + // nonconst is used below to avoid const constructor and to force a new instance + return SizedBox( + height: nonconst(100.0), width: 100.0, ); }), diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index c6ccab28e3..7447140a9a 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -412,15 +412,15 @@ void main() { textDirection: TextDirection.ltr, child: Center( child: Stack( - children: [ - Container( + children: const [ + SizedBox( width: 100.0, height: 100.0, ), Positioned( top: 0.0, left: 0.0, - child: Container( + child: SizedBox( width: 200.0, height: 200.0, ), @@ -442,15 +442,15 @@ void main() { child: Center( child: Stack( overflow: Overflow.visible, - children: [ - Container( + children: const [ + SizedBox( width: 100.0, height: 100.0, ), Positioned( top: 0.0, left: 0.0, - child: Container( + child: SizedBox( width: 200.0, height: 200.0, ),