From c6ef4c75d908c0fd608e6c349c43ec65ea13007b Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Thu, 4 Mar 2021 01:29:02 +0000 Subject: [PATCH] Turn on sized_box_for_whitespace lint, fix instances. (#77099) --- analysis_options.yaml | 2 +- .../print_correct_local_widget_test.dart | 2 +- .../lib/src/simple_scroll.dart | 2 +- .../macrobenchmarks/lib/src/stack_size.dart | 6 +- .../macrobenchmarks/lib/src/text.dart | 6 +- .../external_ui/lib/main.dart | 4 +- .../cupertino/cupertino_refresh_demo.dart | 2 +- .../demo/material/bottom_app_bar_demo.dart | 2 +- .../demo/material/reorderable_list_demo.dart | 2 +- .../demo/shrine/expanding_bottom_sheet.dart | 2 +- .../shrine/supplemental/asymmetric_view.dart | 8 +- ...formations_demo_gesture_transformable.dart | 2 +- .../test_memory/image_cache_memory.dart | 2 +- .../ios_platform_view_tests/lib/main.dart | 6 +- dev/manual_tests/lib/drag_and_drop.dart | 4 +- examples/layers/widgets/spinning_mixed.dart | 2 +- .../lib/src/material/autocomplete.dart | 2 +- .../src/material/calendar_date_picker.dart | 2 +- .../src/material/date_picker_deprecated.dart | 2 +- .../src/material/paginated_data_table.dart | 2 +- .../flutter/lib/src/material/stepper.dart | 2 +- .../flutter/lib/src/material/time_picker.dart | 10 +- .../lib/src/services/platform_channel.dart | 2 +- .../test/cupertino/date_picker_test.dart | 2 +- .../flutter/test/cupertino/picker_test.dart | 28 ++-- .../flutter/test/cupertino/refresh_test.dart | 36 ++-- .../flutter/test/cupertino/route_test.dart | 4 +- .../test/cupertino/text_field_test.dart | 10 +- .../text_selection_toolbar_test.dart | 54 +++--- .../flutter/test/material/app_bar_test.dart | 2 +- .../test/material/bottom_sheet_test.dart | 14 +- .../test/material/button_bar_test.dart | 64 +++---- .../test/material/button_theme_test.dart | 2 +- packages/flutter/test/material/chip_test.dart | 26 +-- .../flutter/test/material/divider_test.dart | 2 +- .../flutter/test/material/dropdown_test.dart | 38 ++--- .../test/material/expansion_tile_test.dart | 64 +++---- .../material/flexible_space_bar_test.dart | 2 +- .../floating_action_button_location_test.dart | 4 +- .../flutter/test/material/ink_paint_test.dart | 10 +- .../flutter/test/material/ink_well_test.dart | 66 ++++---- .../test/material/input_decorator_test.dart | 54 +++--- .../flutter/test/material/list_tile_test.dart | 4 +- .../flutter/test/material/material_test.dart | 4 +- .../persistent_bottom_sheet_test.dart | 64 +++---- .../material/raw_material_button_test.dart | 2 +- .../test/material/refresh_indicator_test.dart | 2 +- .../test/material/reorderable_list_test.dart | 4 +- .../flutter/test/material/scaffold_test.dart | 8 +- .../flutter/test/material/scrollbar_test.dart | 24 +-- .../flutter/test/material/snack_bar_test.dart | 24 +-- .../test/material/text_field_test.dart | 40 ++--- .../material/text_selection_toolbar_test.dart | 29 ++-- .../test/material/time_picker_theme_test.dart | 2 +- .../flutter/test/rendering/viewport_test.dart | 116 ++++++------- .../flutter/test/widgets/actions_test.dart | 4 +- packages/flutter/test/widgets/align_test.dart | 8 +- .../test/widgets/animated_align_test.dart | 28 ++-- .../widgets/automatic_keep_alive_test.dart | 46 +++--- .../flutter/test/widgets/column_test.dart | 124 +++++++------- .../widgets/composited_transform_test.dart | 16 +- .../test/widgets/dismissible_test.dart | 6 +- .../flutter/test/widgets/draggable_test.dart | 102 ++++++------ .../editable_text_show_on_screen_test.dart | 34 ++-- .../test/widgets/ensure_visible_test.dart | 92 +++++------ .../flutter/test/widgets/fitted_box_test.dart | 48 +++--- packages/flutter/test/widgets/flex_test.dart | 32 ++-- .../test/widgets/focus_manager_test.dart | 4 +- .../test/widgets/focus_traversal_test.dart | 48 +++--- .../flutter/test/widgets/framework_test.dart | 2 +- .../test/widgets/gesture_detector_test.dart | 2 +- .../test/widgets/grid_view_layout_test.dart | 4 +- .../flutter/test/widgets/heroes_test.dart | 70 ++++---- .../test/widgets/image_resolution_test.dart | 2 +- .../flutter/test/widgets/image_rtl_test.dart | 56 +++---- .../widgets/implicit_animations_test.dart | 2 +- .../test/widgets/interactive_viewer_test.dart | 60 +++---- .../flutter/test/widgets/keep_alive_test.dart | 2 +- .../test/widgets/list_view_builder_test.dart | 6 +- .../widgets/list_view_correction_test.dart | 98 +++++------ .../widgets/list_view_horizontal_test.dart | 6 +- .../test/widgets/list_view_misc_test.dart | 12 +- .../flutter/test/widgets/list_view_test.dart | 36 ++-- .../widgets/list_view_viewporting_test.dart | 32 ++-- .../list_view_with_inherited_test.dart | 2 +- .../widgets/list_wheel_scroll_view_test.dart | 74 ++++----- .../test/widgets/mouse_region_test.dart | 26 +-- .../test/widgets/nested_scroll_view_test.dart | 44 +++-- .../test/widgets/overflow_box_test.dart | 4 +- .../widgets/overscroll_indicator_test.dart | 6 +- .../test/widgets/pageable_list_test.dart | 4 +- .../test/widgets/physical_model_test.dart | 78 ++++----- .../test/widgets/platform_view_test.dart | 6 +- .../flutter/test/widgets/positioned_test.dart | 2 +- .../test/widgets/reorderable_list_test.dart | 4 +- .../test/widgets/reparent_state_test.dart | 6 +- packages/flutter/test/widgets/row_test.dart | 156 +++++++++--------- .../test/widgets/scroll_activity_test.dart | 2 +- .../test/widgets/scroll_controller_test.dart | 28 ++-- .../test/widgets/scroll_view_test.dart | 2 +- .../test/widgets/scrollable_dispose_test.dart | 2 +- .../scrollable_list_hit_testing_test.dart | 14 +- .../widgets/scrollable_restoration_test.dart | 32 ++-- .../widgets/scrollable_semantics_test.dart | 18 +- ...llable_semantics_traversal_order_test.dart | 12 +- .../flutter/test/widgets/scrollable_test.dart | 10 +- .../test/widgets/selectable_text_test.dart | 24 +-- .../test/widgets/semantics_1_test.dart | 16 +- .../test/widgets/semantics_2_test.dart | 12 +- .../test/widgets/semantics_clipping_test.dart | 32 ++-- .../semantics_keep_alive_offstage_test.dart | 2 +- .../flutter/test/widgets/shortcuts_test.dart | 8 +- .../single_child_scroll_view_test.dart | 32 ++-- .../widgets/sliver_appbar_opacity_test.dart | 2 +- .../test/widgets/sliver_list_test.dart | 10 +- .../test/widgets/sliver_semantics_test.dart | 18 +- .../slivers_appbar_floating_pinned_test.dart | 2 +- .../test/widgets/slivers_keepalive_test.dart | 6 +- .../test/widgets/slivers_padding_test.dart | 8 +- .../flutter/test/widgets/slivers_test.dart | 32 ++-- packages/flutter/test/widgets/stack_test.dart | 46 +++--- packages/flutter/test/widgets/text_test.dart | 10 +- .../tracking_scroll_controller_test.dart | 2 +- .../flutter/test/widgets/transform_test.dart | 8 +- .../widgets/transformed_scrollable_test.dart | 8 +- .../test/src/real_tests/extension_test.dart | 38 ++--- .../flutter_test/test/accessibility_test.dart | 4 +- .../flutter_test/test/controller_test.dart | 2 +- 128 files changed, 1350 insertions(+), 1367 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 3ad417e584..ef0e53f093 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -181,7 +181,7 @@ linter: - provide_deprecation_message # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml - recursive_getters - # - sized_box_for_whitespace # not yet tested + - sized_box_for_whitespace - slash_for_doc_comments # - sort_child_properties_last # not yet tested - sort_constructors_first diff --git a/dev/automated_tests/flutter_test/print_correct_local_widget_test.dart b/dev/automated_tests/flutter_test/print_correct_local_widget_test.dart index a1f5309d93..9999c70eb0 100644 --- a/dev/automated_tests/flutter_test/print_correct_local_widget_test.dart +++ b/dev/automated_tests/flutter_test/print_correct_local_widget_test.dart @@ -14,7 +14,7 @@ void main() { appBar: AppBar( title: const Text('RenderFlex OverFlow'), ), - body: Container( + body: SizedBox( width: 400.0, child: Row( children: [ diff --git a/dev/benchmarks/macrobenchmarks/lib/src/simple_scroll.dart b/dev/benchmarks/macrobenchmarks/lib/src/simple_scroll.dart index 1797ff4c38..2050886dc0 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/simple_scroll.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/simple_scroll.dart @@ -12,7 +12,7 @@ class SimpleScroll extends StatelessWidget { return ListView( children: [ for (int n = 0; n < 200; n += 1) - Container(height: 40.0, child: Text('$n')), + SizedBox(height: 40.0, child: Text('$n')), ], ); } diff --git a/dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart b/dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart index 8083833652..821a795091 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart @@ -87,11 +87,11 @@ class StackSizePage extends StatelessWidget { Widget build(BuildContext context) { return Material( child: Column( - children: [ - Container( + children: const [ + SizedBox( width: 200, height: 100, - child: const ParentWidget(), + child: ParentWidget(), ), ], ), diff --git a/dev/benchmarks/macrobenchmarks/lib/src/text.dart b/dev/benchmarks/macrobenchmarks/lib/src/text.dart index 1ece1262b2..c89cb2d359 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/text.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/text.dart @@ -11,11 +11,11 @@ class TextPage extends StatelessWidget { Widget build(BuildContext context) { return Material( child: Column( - children: [ - Container( + children: const [ + SizedBox( width: 200, height: 100, - child: const TextField( + child: TextField( key: Key('basic-textfield'), ), ), diff --git a/dev/integration_tests/external_ui/lib/main.dart b/dev/integration_tests/external_ui/lib/main.dart index 91dd041ed2..83e9b485ac 100644 --- a/dev/integration_tests/external_ui/lib/main.dart +++ b/dev/integration_tests/external_ui/lib/main.dart @@ -136,10 +136,10 @@ Press play to produce texture frames.'''; child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container( + const SizedBox( width: 300.0, height: 200.0, - child: const Texture(textureId: 0), + child: Texture(textureId: 0), ), Container( width: 300.0, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart index e86a4be710..dee1a650b3 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart @@ -164,7 +164,7 @@ class _ListItem extends StatelessWidget { padding: const EdgeInsets.only(top: 9.0), child: Row( children: [ - Container( + SizedBox( width: 38.0, child: called! ? Align( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart index 51c22d73f2..5aa7278d79 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart @@ -433,7 +433,7 @@ class _DiamondFab extends StatelessWidget { color: Colors.orange, child: InkWell( onTap: onPressed, - child: Container( + child: SizedBox( width: 56.0, height: 56.0, child: IconTheme.merge( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart index 15fc2c193b..c20d76e82a 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart @@ -146,7 +146,7 @@ class _ListDemoState extends State { break; case _ReorderableListType.horizontalAvatar: case _ReorderableListType.verticalAvatar: - listTile = Container( + listTile = SizedBox( key: Key(item.value), height: 100.0, width: 100.0, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart index 4699951846..70d5551156 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart @@ -324,7 +324,7 @@ class _ExpandingBottomSheetState extends State with Ticker return Semantics( button: true, value: 'Shopping cart, $totalCartQuantity items', - child: Container( + child: SizedBox( width: _widthAnimation.value, height: _heightAnimation.value, child: Material( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart index 9cbce63fde..689183aa20 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/supplemental/asymmetric_view.dart @@ -12,9 +12,9 @@ class AsymmetricView extends StatelessWidget { final List? products; - List _buildColumns(BuildContext context) { + List _buildColumns(BuildContext context) { if (products == null || products!.isEmpty) { - return const []; + return const []; } // This will return a list of columns. It will oscillate between the two @@ -25,7 +25,7 @@ class AsymmetricView extends StatelessWidget { // some kinda awkward math so we use _evenCasesIndex and _oddCasesIndex as // helpers for creating the index of the product list that will correspond // to the index of the list of columns. - return List.generate(_listItemCount(products!.length), (int index) { + return List.generate(_listItemCount(products!.length), (int index) { double width = .59 * MediaQuery.of(context).size.width; Widget column; if (index.isEven) { @@ -44,7 +44,7 @@ class AsymmetricView extends StatelessWidget { product: products![_oddCasesIndex(index)], ); } - return Container( + return SizedBox( width: width, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), diff --git a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart index ca873cecd9..b3d3f137e7 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart @@ -286,7 +286,7 @@ class _GestureTransformableState extends State with Ticker // The scene is panned/zoomed/rotated using this Transform widget. child: Transform( transform: _transform, - child: Container( + child: SizedBox( child: widget.child, height: widget.size.height, width: widget.size.width, diff --git a/dev/integration_tests/flutter_gallery/test_memory/image_cache_memory.dart b/dev/integration_tests/flutter_gallery/test_memory/image_cache_memory.dart index 98560d0d25..b8acced647 100644 --- a/dev/integration_tests/flutter_gallery/test_memory/image_cache_memory.dart +++ b/dev/integration_tests/flutter_gallery/test_memory/image_cache_memory.dart @@ -20,7 +20,7 @@ Future main() async { key: const Key('ImageList'), itemCount: numItems, itemBuilder: (BuildContext context, int position) { - return Container( + return SizedBox( width: 200, height: 200, child: Center( diff --git a/dev/integration_tests/ios_platform_view_tests/lib/main.dart b/dev/integration_tests/ios_platform_view_tests/lib/main.dart index aafc0907fa..d1642ad9bf 100644 --- a/dev/integration_tests/ios_platform_view_tests/lib/main.dart +++ b/dev/integration_tests/ios_platform_view_tests/lib/main.dart @@ -81,9 +81,9 @@ class PlatformViewPage extends StatelessWidget { ), body: Column( children: [ - Expanded( - child: Container( - child: const UiKitView(viewType: 'platform_view'), + const Expanded( + child: SizedBox( + child: UiKitView(viewType: 'platform_view'), width: 300, ), ), diff --git a/dev/manual_tests/lib/drag_and_drop.dart b/dev/manual_tests/lib/drag_and_drop.dart index d4e4704ded..9af6d44c59 100644 --- a/dev/manual_tests/lib/drag_and_drop.dart +++ b/dev/manual_tests/lib/drag_and_drop.dart @@ -198,10 +198,10 @@ class MovableBall extends StatelessWidget { child: const Center(child: Text('BALL')), ), ); - final Widget dashedBall = Container( + const Widget dashedBall = SizedBox( width: kBallSize, height: kBallSize, - child: const CustomPaint( + child: CustomPaint( painter: DashOutlineCirclePainter() ), ); diff --git a/examples/layers/widgets/spinning_mixed.dart b/examples/layers/widgets/spinning_mixed.dart index c29e3aacd2..fc893c7b13 100644 --- a/examples/layers/widgets/spinning_mixed.dart +++ b/examples/layers/widgets/spinning_mixed.dart @@ -38,7 +38,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) { container: container, child: Directionality( textDirection: TextDirection.ltr, - child: Container( + child: SizedBox( height: 300.0, child: Column( children: [ diff --git a/packages/flutter/lib/src/material/autocomplete.dart b/packages/flutter/lib/src/material/autocomplete.dart index 786ba4a2ad..6be42d7030 100644 --- a/packages/flutter/lib/src/material/autocomplete.dart +++ b/packages/flutter/lib/src/material/autocomplete.dart @@ -228,7 +228,7 @@ class _AutocompleteOptions extends StatelessWidget { alignment: Alignment.topLeft, child: Material( elevation: 4.0, - child: Container( + child: SizedBox( height: 200.0, child: ListView.builder( padding: EdgeInsets.zero, diff --git a/packages/flutter/lib/src/material/calendar_date_picker.dart b/packages/flutter/lib/src/material/calendar_date_picker.dart index bd49311dcd..ed10221a94 100644 --- a/packages/flutter/lib/src/material/calendar_date_picker.dart +++ b/packages/flutter/lib/src/material/calendar_date_picker.dart @@ -383,7 +383,7 @@ class _DatePickerModeToggleButtonState extends State<_DatePickerModeToggleButton label: MaterialLocalizations.of(context).selectYearSemanticsLabel, excludeSemantics: true, button: true, - child: Container( + child: SizedBox( height: _subHeaderHeight, child: InkWell( onTap: widget.onTitlePressed, diff --git a/packages/flutter/lib/src/material/date_picker_deprecated.dart b/packages/flutter/lib/src/material/date_picker_deprecated.dart index fdace05bc7..655eaecca7 100644 --- a/packages/flutter/lib/src/material/date_picker_deprecated.dart +++ b/packages/flutter/lib/src/material/date_picker_deprecated.dart @@ -314,7 +314,7 @@ class DayPicker extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Column( children: [ - Container( + SizedBox( height: _kDayPickerRowHeight, child: Center( child: ExcludeSemantics( diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index 80e14da7b1..c1a2a26b8a 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -539,7 +539,7 @@ class PaginatedDataTableState extends State { data: const IconThemeData( opacity: 0.54 ), - child: Container( + child: SizedBox( // TODO(bkonyi): this won't handle text zoom correctly, // https://github.com/flutter/flutter/issues/48522 height: 56.0, diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 84d337fec9..9881fcf49f 100755 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -682,7 +682,7 @@ class _StepperState extends State with TickerProviderStateMixin { canRequestFocus: widget.steps[i].state != StepState.disabled, child: Row( children: [ - Container( + SizedBox( height: 72.0, child: Center( child: _buildIcon(i), diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index ac55f01555..4062663cea 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -159,7 +159,7 @@ class _TimePickerHeader extends StatelessWidget { controls = Column( children: [ const SizedBox(height: 16.0), - Container( + SizedBox( height: kMinInteractiveDimension * 2, child: Row( children: [ @@ -209,7 +209,7 @@ class _TimePickerHeader extends StatelessWidget { orientation: orientation, onChanged: onChanged, ), - Container( + SizedBox( height: kMinInteractiveDimension * 2, child: Row( // Hour/minutes should not change positions in RTL locales. @@ -287,7 +287,7 @@ class _HourMinuteControl extends StatelessWidget { final ShapeBorder shape = timePickerTheme.hourMinuteShape ?? _kDefaultShape; final Set states = isSelected ? {MaterialState.selected} : {}; - return Container( + return SizedBox( height: _kTimePickerHeaderControlHeight, child: Material( color: MaterialStateProperty.resolveAs(backgroundColor, states), @@ -610,7 +610,7 @@ class _DayPeriodControl extends StatelessWidget { result = _DayPeriodInputPadding( minSize: const Size(width, kMinInteractiveDimension * 2), orientation: orientation, - child: Container( + child: SizedBox( width: width, height: _kTimePickerHeaderControlHeight, child: Material( @@ -637,7 +637,7 @@ class _DayPeriodControl extends StatelessWidget { result = _DayPeriodInputPadding( minSize: const Size(0.0, kMinInteractiveDimension), orientation: orientation, - child: Container( + child: SizedBox( height: 40.0, child: Material( clipBehavior: Clip.antiAlias, diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index 3f9383e9f1..8996ae0156 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -292,7 +292,7 @@ class MethodChannel { /// NSArray* items = [BWPlayApi items]; /// NSMutableArray* json = [NSMutableArray arrayWithCapacity:items.count]; /// for (final BWPlayItem* item in items) { - /// [json addObject:@{@"id":item.itemId, @"title":item.name, @"artist":item.artist}]; + /// [json addObject:@{ @"id":item.itemId, @"title":item.name, @"artist":item.artist }]; /// } /// result(json); /// } else if ([@"play" isEqualToString:call.method]) { diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 91b4cece27..cd047bd65e 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -1502,7 +1502,7 @@ Widget _buildPicker({ onSelectedItemChanged: onSelectedItemChanged, children: List.generate(100, (int index) { return Center( - child: Container( + child: SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), diff --git a/packages/flutter/test/cupertino/picker_test.dart b/packages/flutter/test/cupertino/picker_test.dart index 878076ae71..62f422afcd 100644 --- a/packages/flutter/test/cupertino/picker_test.dart +++ b/packages/flutter/test/cupertino/picker_test.dart @@ -22,7 +22,7 @@ void main() { itemExtent: 50.0, onSelectedItemChanged: (_) { }, children: List.generate(3, (int index) { - return Container( + return SizedBox( height: 50.0, width: 300.0, child: Text(index.toString()), @@ -65,7 +65,7 @@ void main() { itemExtent: 50.0, onSelectedItemChanged: (_) { }, children: List.generate(3, (int index) { - return Container( + return SizedBox( height: 50.0, width: 300.0, child: Text(index.toString()), @@ -78,7 +78,7 @@ void main() { ); expect( - tester.getTopLeft(find.widgetWithText(Container, '1')), + tester.getTopLeft(find.widgetWithText(SizedBox, '1').first), const Offset(0.0, 125.0), ); @@ -86,11 +86,11 @@ void main() { await tester.pump(); expect( - tester.getTopLeft(find.widgetWithText(Container, '1')), + tester.getTopLeft(find.widgetWithText(SizedBox, '1').first), const Offset(0.0, 175.0), ); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0').first), const Offset(0.0, 125.0), ); }); @@ -191,7 +191,7 @@ void main() { onSelectedItemChanged: (int index) { selectedItems.add(index); }, children: List.generate(100, (int index) { return Center( - child: Container( + child: SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -242,7 +242,7 @@ void main() { onSelectedItemChanged: (int index) { selectedItems.add(index); }, children: List.generate(100, (int index) { return Center( - child: Container( + child: SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -272,7 +272,7 @@ void main() { onSelectedItemChanged: (int index) { selectedItems.add(index); }, children: List.generate(100, (int index) { return Center( - child: Container( + child: SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -288,14 +288,14 @@ void main() { // The item that was in the center now moved a bit. expect( - tester.getTopLeft(find.widgetWithText(Container, '10')), + tester.getTopLeft(find.widgetWithText(SizedBox, '10')), const Offset(200.0, 280.0), ); await tester.pumpAndSettle(); expect( - tester.getTopLeft(find.widgetWithText(Container, '10')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '10')).dy, moreOrLessEquals(250.0, epsilon: 0.5), ); expect(selectedItems.isEmpty, true); @@ -306,7 +306,7 @@ void main() { await tester.pumpAndSettle(); expect( - tester.getTopLeft(find.widgetWithText(Container, '10')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '10')).dy, // It's down by 100.0 now. moreOrLessEquals(350.0, epsilon: 0.5), ); @@ -327,7 +327,7 @@ void main() { onSelectedItemChanged: (int index) { selectedItems.add(index); }, children: List.generate(100, (int index) { return Center( - child: Container( + child: SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -348,7 +348,7 @@ void main() { // Should have been flung far enough that even the first item goes off // screen and gets removed. - expect(find.widgetWithText(Container, '0').evaluate().isEmpty, true); + expect(find.widgetWithText(SizedBox, '0').evaluate().isEmpty, true); expect( selectedItems, @@ -361,7 +361,7 @@ void main() { await tester.pumpAndSettle(); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, // Should have sprung back to the middle now. moreOrLessEquals(250.0), ); diff --git a/packages/flutter/test/cupertino/refresh_test.dart b/packages/flutter/test/cupertino/refresh_test.dart index c254d10c24..4d8339a4b0 100644 --- a/packages/flutter/test/cupertino/refresh_test.dart +++ b/packages/flutter/test/cupertino/refresh_test.dart @@ -21,7 +21,7 @@ void main() { return SliverList( delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - return Container( + return SizedBox( height: 200.0, child: Center(child: Text(index.toString())), ); @@ -50,7 +50,7 @@ void main() { expect(mockHelper.invocations, isEmpty); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), Offset.zero, ); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); @@ -85,7 +85,7 @@ void main() { expect(mockHelper.invocations, hasLength(1)); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), const Offset(0.0, 50.0), ); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); @@ -114,7 +114,7 @@ void main() { expect(mockHelper.invocations, isEmpty); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), Offset.zero, ); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); @@ -165,7 +165,7 @@ void main() { expect(mockHelper.invocations, hasLength(3)); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), Offset.zero, ); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); @@ -282,7 +282,7 @@ void main() { // Stays in that state forever until future completes. await tester.pump(const Duration(seconds: 1000)); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), const Offset(0.0, 60.0), ); @@ -355,7 +355,7 @@ void main() { // Stays in that state forever until future completes. await tester.pump(const Duration(seconds: 1000)); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), const Offset(0.0, 60.0), ); @@ -840,8 +840,8 @@ void main() { ), ); - await tester.fling(find.byType(Container).first, const Offset(0.0, 200.0), 2000.0); - await tester.fling(find.byType(Container).first, const Offset(0.0, -200.0), 3000.0, warnIfMissed: false); // IgnorePointer is enabled while scroll is ballistic. + await tester.fling(find.byType(SizedBox).first, const Offset(0.0, 200.0), 2000.0); + await tester.fling(find.byType(SizedBox).first, const Offset(0.0, -200.0), 3000.0, warnIfMissed: false); // IgnorePointer is enabled while scroll is ballistic. expect(mockHelper.invocations, isEmpty); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); @@ -937,7 +937,7 @@ void main() { ), ); - final double initialFirstCellY = tester.getTopLeft(find.widgetWithText(Container, '0')).dy; + final double initialFirstCellY = tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy; // Drag down but not enough to trigger the refresh. await tester.drag(find.text('0'), const Offset(0.0, 50.0), touchSlopY: 0); @@ -952,7 +952,7 @@ void main() { expect(mockHelper.invocations, hasLength(1)); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, initialFirstCellY + 50 ); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); @@ -1074,7 +1074,7 @@ void main() { await gesture.moveBy(const Offset(0.0, -80.0)); // Overscrolling, need to move more than -40. await tester.pump(); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, moreOrLessEquals(49.775111111111116), // Below 50 now. ); expect( @@ -1116,7 +1116,7 @@ void main() { RefreshIndicatorMode.refresh, ); expect( - tester.getRect(find.widgetWithText(Container, '0')), + tester.getRect(find.widgetWithText(SizedBox, '0')), const Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), ); @@ -1167,7 +1167,7 @@ void main() { await gesture.moveBy(const Offset(0.0, -200.0)); await tester.pump(); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, moreOrLessEquals(27.944444444444457), ); // Need to bring it to 100 * 0.1 to reset to inactive. @@ -1179,7 +1179,7 @@ void main() { await gesture.moveBy(const Offset(0.0, -35.0)); await tester.pump(); expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, moreOrLessEquals(9.313890708161875), ); expect( @@ -1219,7 +1219,7 @@ void main() { await tester.pump(); // The refresh indicator is offscreen now. expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, moreOrLessEquals(-145.0332383665717), ); expect( @@ -1236,13 +1236,13 @@ void main() { ); // Nothing moved. expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, moreOrLessEquals(-145.0332383665717), ); await tester.pump(const Duration(seconds: 2)); // Everything stayed as is. expect( - tester.getTopLeft(find.widgetWithText(Container, '0')).dy, + tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy, moreOrLessEquals(-145.0332383665717), ); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index a2a187e87b..17d1dd871b 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -1118,7 +1118,7 @@ void main() { child: Hero( tag: 'tag', transitionOnUserGestures: true, - child: Container(key: container, height: 150.0, width: 150.0) + child: SizedBox(key: container, height: 150.0, width: 150.0) ), ) ); @@ -1131,7 +1131,7 @@ void main() { child: Hero( tag: 'tag', transitionOnUserGestures: true, - child: Container(key: container, height: 150.0, width: 150.0) + child: SizedBox(key: container, height: 150.0, width: 150.0) ) ), ) diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index c2ecf47e4c..6f7093c588 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -4217,7 +4217,7 @@ void main() { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Container( + SizedBox( width: 100.0, child: CupertinoTextField( controller: controller1, @@ -4228,21 +4228,21 @@ void main() { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Container( + SizedBox( width: 100.0, child: CupertinoTextField( controller: controller2, focusNode: focusNode2, ), ), - Container( + SizedBox( width: 100.0, child: CupertinoTextField( controller: controller3, focusNode: focusNode3, ), ), - Container( + SizedBox( width: 100.0, child: CupertinoTextField( controller: controller4, @@ -4251,7 +4251,7 @@ void main() { ), ], ), - Container( + SizedBox( width: 100.0, child: CupertinoTextField( controller: controller5, diff --git a/packages/flutter/test/cupertino/text_selection_toolbar_test.dart b/packages/flutter/test/cupertino/text_selection_toolbar_test.dart index 91bf60bf55..490d92a2f2 100644 --- a/packages/flutter/test/cupertino/text_selection_toolbar_test.dart +++ b/packages/flutter/test/cupertino/text_selection_toolbar_test.dart @@ -54,6 +54,13 @@ class _CustomCupertinoTextSelectionControls extends CupertinoTextSelectionContro } } +class TestBox extends SizedBox { + const TestBox({Key? key}) : super(key: key, width: itemWidth, height: itemHeight); + + static const double itemHeight = 44.0; + static const double itemWidth = 100.0; +} + void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -75,18 +82,7 @@ void main() { testWidgets('paginates children if they overflow', (WidgetTester tester) async { late StateSetter setState; - const double height = 44.0; - const double itemWidth = 100.0; - final List children = [ - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - ]; - + final List children = List.generate(7, (int i) => const TestBox()); await tester.pumpWidget( CupertinoApp( home: Center( @@ -105,25 +101,25 @@ void main() { ); // All children fit on the screen, so they are all rendered. - expect(find.byType(Container), findsNWidgets(children.length)); + expect(find.byType(TestBox), findsNWidgets(children.length)); expect(_findOverflowNextButton(), findsNothing); expect(_findOverflowBackButton(), findsNothing); // Adding one more child makes the children overflow. setState(() { children.add( - Container(width: itemWidth, height: height), + const TestBox(), ); }); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(children.length - 1)); + expect(find.byType(TestBox), findsNWidgets(children.length - 1)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsNothing); // Tap the overflow next button to show the next page of children. await tester.tap(_findOverflowNextButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(1)); + expect(find.byType(TestBox), findsNWidgets(1)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsOneWidget); @@ -131,28 +127,28 @@ void main() { // disabled and there are no more children to display. await tester.tap(_findOverflowNextButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(1)); + expect(find.byType(TestBox), findsNWidgets(1)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsOneWidget); // Tap the overflow back button to go back to the first page. await tester.tap(_findOverflowBackButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(7)); + expect(find.byType(TestBox), findsNWidgets(7)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsNothing); // Adding 7 more children overflows onto a third page. setState(() { - children.add(Container(width: itemWidth, height: height)); - children.add(Container(width: itemWidth, height: height)); - children.add(Container(width: itemWidth, height: height)); - children.add(Container(width: itemWidth, height: height)); - children.add(Container(width: itemWidth, height: height)); - children.add(Container(width: itemWidth, height: height)); + children.add(const TestBox()); + children.add(const TestBox()); + children.add(const TestBox()); + children.add(const TestBox()); + children.add(const TestBox()); + children.add(const TestBox()); }); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(7)); + expect(find.byType(TestBox), findsNWidgets(7)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsNothing); @@ -160,28 +156,28 @@ void main() { await tester.tap(_findOverflowNextButton()); await tester.pumpAndSettle(); // With the back button, only six children fit on this page. - expect(find.byType(Container), findsNWidgets(6)); + expect(find.byType(TestBox), findsNWidgets(6)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsOneWidget); // Tap the overflow next button again to show the third page of children. await tester.tap(_findOverflowNextButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(1)); + expect(find.byType(TestBox), findsNWidgets(1)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsOneWidget); // Tap the overflow back button to go back to the second page. await tester.tap(_findOverflowBackButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(6)); + expect(find.byType(TestBox), findsNWidgets(6)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsOneWidget); // Tap the overflow back button to go back to the first page. await tester.tap(_findOverflowBackButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(7)); + expect(find.byType(TestBox), findsNWidgets(7)); expect(_findOverflowNextButton(), findsOneWidget); expect(_findOverflowBackButton(), findsNothing); }, skip: kIsWeb); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 2d5e5a66f9..d54a4ead1f 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -487,7 +487,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Center( - child: Container( + child: SizedBox( height: 0.0, width: 0.0, child: Scaffold( diff --git a/packages/flutter/test/material/bottom_sheet_test.dart b/packages/flutter/test/material/bottom_sheet_test.dart index 65a8f85d79..b9626461ee 100644 --- a/packages/flutter/test/material/bottom_sheet_test.dart +++ b/packages/flutter/test/material/bottom_sheet_test.dart @@ -750,7 +750,7 @@ void main() { ); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -802,18 +802,16 @@ void main() { reverseDuration: const Duration(seconds: 2), ), builder: (BuildContext context) { - return Container( - child: MaterialButton( - child: const Text('BottomSheet'), - onPressed: () => Navigator.pop(context), - key: tapTargetToClose, - ), + return MaterialButton( + child: const Text('BottomSheet'), + onPressed: () => Navigator.pop(context), + key: tapTargetToClose, ); }, ); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), diff --git a/packages/flutter/test/material/button_bar_test.dart b/packages/flutter/test/material/button_bar_test.dart index c5e6a31110..f00f095f7a 100644 --- a/packages/flutter/test/material/button_bar_test.dart +++ b/packages/flutter/test/material/button_bar_test.dart @@ -90,16 +90,16 @@ void main() { const Key child2Key = Key('child2'); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Center( child: ButtonBar( key: buttonBarKey, // buttonPadding set to zero to simplify test calculations. buttonPadding: EdgeInsets.zero, children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), ), @@ -136,9 +136,9 @@ void main() { const Key child1Key = Key('child1'); const Key child2Key = Key('child2'); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: ButtonBarTheme( - data: const ButtonBarThemeData( + data: ButtonBarThemeData( mainAxisSize: MainAxisSize.min, ), child: Center( @@ -147,9 +147,9 @@ void main() { // buttonPadding set to zero to simplify test calculations. buttonPadding: EdgeInsets.zero, children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), ), @@ -191,9 +191,9 @@ void main() { const Key child1Key = Key('child1'); const Key child2Key = Key('child2'); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: ButtonBarTheme( - data: const ButtonBarThemeData( + data: ButtonBarThemeData( mainAxisSize: MainAxisSize.min, ), child: Center( @@ -203,9 +203,9 @@ void main() { buttonPadding: EdgeInsets.zero, mainAxisSize: MainAxisSize.max, children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), ), @@ -394,8 +394,8 @@ void main() { MaterialApp( home: ButtonBar( children: [ - Container(key: keyOne, height: 50.0, width: 800.0), - Container(key: keyTwo, height: 50.0, width: 800.0), + SizedBox(key: keyOne, height: 50.0, width: 800.0), + SizedBox(key: keyTwo, height: 50.0, width: 800.0), ], ), ), @@ -419,8 +419,8 @@ void main() { // Set padding to zero to align buttons with edge of button bar. buttonPadding: EdgeInsets.zero, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), @@ -447,8 +447,8 @@ void main() { // Set padding to zero to align buttons with edge of button bar. buttonPadding: EdgeInsets.zero, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), @@ -474,8 +474,8 @@ void main() { // Set padding to zero to align buttons with edge of button bar. buttonPadding: EdgeInsets.zero, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), @@ -504,8 +504,8 @@ void main() { // Set padding to zero to align buttons with edge of button bar. buttonPadding: EdgeInsets.zero, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), @@ -527,8 +527,8 @@ void main() { // Set padding to zero to align buttons with edge of button bar. buttonPadding: EdgeInsets.zero, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), @@ -560,8 +560,8 @@ void main() { // out upwards. overflowDirection: VerticalDirection.up, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), @@ -586,8 +586,8 @@ void main() { // Set padding to zero to align buttons with edge of button bar. buttonPadding: EdgeInsets.zero, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), @@ -614,8 +614,8 @@ void main() { // buttons in an overflow case. overflowButtonSpacing: 10.0, children: [ - Container(key: keyOne, height: 50.0, width: 500.0), - Container(key: keyTwo, height: 50.0, width: 500.0), + SizedBox(key: keyOne, height: 50.0, width: 500.0), + SizedBox(key: keyTwo, height: 50.0, width: 500.0), ], ), ), diff --git a/packages/flutter/test/material/button_theme_test.dart b/packages/flutter/test/material/button_theme_test.dart index fd1e1fe649..0bb9d0b9ae 100644 --- a/packages/flutter/test/material/button_theme_test.dart +++ b/packages/flutter/test/material/button_theme_test.dart @@ -242,7 +242,7 @@ void main() { return Container( alignment: Alignment.center, child: DropdownButtonHideUnderline( - child: Container( + child: SizedBox( width: 200.0, child: DropdownButton( key: dropdownKey, diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index 22789a4cf4..07d5b756ec 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -105,12 +105,12 @@ Future _testConstrainedLabel( await tester.pumpWidget( _wrapForChip( child: Center( - child: Container( + child: SizedBox( width: chipParentWidth, height: chipParentHeight, child: Chip( avatar: avatar, - label: Container( + label: SizedBox( key: labelKey, width: labelWidth, height: labelHeight, @@ -321,13 +321,13 @@ void main() { await tester.pumpWidget( _wrapForChip( child: Center( - child: Container( + child: SizedBox( width: 500.0, height: 500.0, child: Column( children: [ Chip( - label: Container( + label: SizedBox( key: labelKey, width: labelWidth, height: labelHeight, @@ -396,7 +396,7 @@ void main() { Widget chipBuilder (String text, {Widget? avatar, VoidCallback? onDeleted}) { return MaterialApp( home: Scaffold( - body: Container( + body: SizedBox( width: 150, child: Column( children: [ @@ -634,7 +634,7 @@ void main() { ), Chip( avatar: const CircleAvatar(child: Text('B')), - label: Container(key: keyB, width: 10.0, height: 10.0), + label: SizedBox(key: keyB, width: 10.0, height: 10.0), ), ], ), @@ -662,7 +662,7 @@ void main() { child: Column( children: [ Chip( - avatar: Container(key: keyA, width: 20.0, height: 20.0), + avatar: SizedBox(key: keyA, width: 20.0, height: 20.0), label: const Text('Chip A'), ), ], @@ -680,7 +680,7 @@ void main() { child: Column( children: [ Chip( - deleteIcon: Container(key: keyA, width: 20.0, height: 20.0), + deleteIcon: SizedBox(key: keyA, width: 20.0, height: 20.0), label: const Text('Chip A'), onDeleted: () { }, ), @@ -706,7 +706,7 @@ void main() { child: Center( child: Chip( avatar: Placeholder(key: keyA), - label: Container( + label: SizedBox( key: keyB, width: 40.0, height: 40.0, @@ -743,7 +743,7 @@ void main() { child: Center( child: Chip( avatar: Placeholder(key: keyA), - label: Container( + label: SizedBox( key: keyB, width: 40.0, height: 40.0, @@ -1226,13 +1226,13 @@ void main() { // With avatar, but not selectable. final UniqueKey avatarKey = UniqueKey(); await pushChip( - avatar: Container(width: 40.0, height: 40.0, key: avatarKey), + avatar: SizedBox(width: 40.0, height: 40.0, key: avatarKey), ); expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 48.0))); // Turn on selection. await pushChip( - avatar: Container(width: 40.0, height: 40.0, key: avatarKey), + avatar: SizedBox(width: 40.0, height: 40.0, key: avatarKey), selectable: true, ); await tester.pumpAndSettle(); @@ -1384,7 +1384,7 @@ void main() { final UniqueKey avatarKey = UniqueKey(); await pushChip( - avatar: Container(width: 40.0, height: 40.0, key: avatarKey), + avatar: SizedBox(width: 40.0, height: 40.0, key: avatarKey), selectable: true, ); await tester.pumpAndSettle(); diff --git a/packages/flutter/test/material/divider_test.dart b/packages/flutter/test/material/divider_test.dart index 195019c465..f6dfd5b05d 100644 --- a/packages/flutter/test/material/divider_test.dart +++ b/packages/flutter/test/material/divider_test.dart @@ -130,7 +130,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: Container( + child: SizedBox( height: 24.0, child: Row( children: const [ diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index b96086f0f2..936fb87b4f 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -1601,7 +1601,7 @@ void main() { itemHeight: null, selectedItemBuilder: (BuildContext context) { return items.map((String item) { - return Container( + return SizedBox( height: double.parse(item), width: double.parse(item), child: Center(child: Text(item)), @@ -1629,16 +1629,16 @@ void main() { await tester.pumpWidget(buildFrame( value: null, // [hint] widget is smaller than largest selected item widget - hint: Container( + hint: const SizedBox( height: 50, width: 50, - child: const Text('hint') + child: Text('hint') ), items: items, itemHeight: null, selectedItemBuilder: (BuildContext context) { return items.map((String item) { - return Container( + return SizedBox( height: double.parse(item), width: double.parse(item), child: Center(child: Text(item)), @@ -1671,16 +1671,16 @@ void main() { // to the largest item regardless of which one is selected. value: selectedItem, // [hint] widget is larger than largest selected item widget - hint: Container( + hint: const SizedBox( height: 125, width: 125, - child: const Text('hint') + child: Text('hint'), ), items: items, itemHeight: null, selectedItemBuilder: (BuildContext context) { return items.map((String item) { - return Container( + return SizedBox( height: double.parse(item), width: double.parse(item), child: Center(child: Text(item)), @@ -1709,16 +1709,16 @@ void main() { await tester.pumpWidget(buildFrame( value: null, // [hint] widget is smaller than largest selected item widget - hint: Container( + hint: const SizedBox( height: 50, width: 50, - child: const Text('hint') + child: Text('hint'), ), items: items, itemHeight: null, selectedItemBuilder: (BuildContext context) { return items.map((String item) { - return Container( + return SizedBox( height: double.parse(item), width: double.parse(item), child: Center(child: Text(item)), @@ -1747,16 +1747,16 @@ void main() { await tester.pumpWidget(buildFrame( value: null, // [hint] widget is larger than largest selected item widget - hint: Container( + hint: const SizedBox( height: 125, width: 125, - child: const Text('hint') + child: Text('hint') ), items: items, itemHeight: null, selectedItemBuilder: (BuildContext context) { return items.map((String item) { - return Container( + return SizedBox( height: double.parse(item), width: double.parse(item), child: Center(child: Text(item)), @@ -1785,16 +1785,16 @@ void main() { await tester.pumpWidget(buildFrame( value: null, // [hint] widget is smaller than largest selected item widget - disabledHint: Container( + disabledHint: const SizedBox( height: 50, width: 50, - child: const Text('hint') + child: Text('hint') ), items: items, itemHeight: null, selectedItemBuilder: (BuildContext context) { return items.map((String item) { - return Container( + return SizedBox( height: double.parse(item), width: double.parse(item), child: Center(child: Text(item)), @@ -1823,16 +1823,16 @@ void main() { await tester.pumpWidget(buildFrame( value: null, // [hint] widget is larger than largest selected item widget - disabledHint: Container( + disabledHint: const SizedBox( height: 125, width: 125, - child: const Text('hint') + child: Text('hint') ), items: items, itemHeight: null, selectedItemBuilder: (BuildContext context) { return items.map((String item) { - return Container( + return SizedBox( height: double.parse(item), width: double.parse(item), child: Center(child: Text(item)), diff --git a/packages/flutter/test/material/expansion_tile_test.dart b/packages/flutter/test/material/expansion_tile_test.dart index 2c15922af0..d2b23164ec 100644 --- a/packages/flutter/test/material/expansion_tile_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -297,15 +297,15 @@ void main() { }); testWidgets('ExpansionTile expandedAlignment test', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( + await tester.pumpWidget(const MaterialApp( home: Material( child: Center( child: ExpansionTile( - title: const Text('title'), + title: Text('title'), expandedAlignment: Alignment.centerLeft, children: [ - Container(height: 100, width: 100), - Container(height: 100, width: 80), + SizedBox(height: 100, width: 100), + SizedBox(height: 100, width: 80), ], ), ), @@ -339,9 +339,9 @@ void main() { // and expandedCrossAxisAlignment later in the test. expandedAlignment: Alignment.centerRight, expandedCrossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container(height: 100, width: 100, key: child0Key), - Container(height: 100, width: 80, key: child1Key), + children: const [ + SizedBox(height: 100, width: 100, key: child0Key), + SizedBox(height: 100, width: 80, key: child1Key), ], ), ), @@ -391,14 +391,14 @@ void main() { testWidgets('expandedCrossAxisAlignment and expandedAlignment default values', (WidgetTester tester) async { const Key child1Key = Key('child1'); - await tester.pumpWidget(MaterialApp( + await tester.pumpWidget(const MaterialApp( home: Material( child: Center( child: ExpansionTile( - title: const Text('title'), + title: Text('title'), children: [ - Container(height: 100, width: 100), - Container(height: 100, width: 80, key: child1Key), + SizedBox(height: 100, width: 100), + SizedBox(height: 100, width: 80, key: child1Key), ], ), ), @@ -424,18 +424,20 @@ void main() { }); testWidgets('childrenPadding default value', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: Material( - child: Center( - child: ExpansionTile( - title: const Text('title'), - children: [ - Container(height: 100, width: 100), - ], + await tester.pumpWidget( + const MaterialApp( + home: Material( + child: Center( + child: ExpansionTile( + title: Text('title'), + children: [ + SizedBox(height: 100, width: 100), + ], + ), ), ), ), - )); + ); await tester.tap(find.text('title')); await tester.pumpAndSettle(); @@ -452,19 +454,21 @@ void main() { }); testWidgets('ExpansionTile childrenPadding test', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: Material( - child: Center( - child: ExpansionTile( - title: const Text('title'), - childrenPadding: const EdgeInsets.fromLTRB(10, 8, 12, 4), - children: [ - Container(height: 100, width: 100), - ], + await tester.pumpWidget( + const MaterialApp( + home: Material( + child: Center( + child: ExpansionTile( + title: Text('title'), + childrenPadding: EdgeInsets.fromLTRB(10, 8, 12, 4), + children: [ + SizedBox(height: 100, width: 100), + ], + ), ), ), ), - )); + ); await tester.tap(find.text('title')); await tester.pumpAndSettle(); diff --git a/packages/flutter/test/material/flexible_space_bar_test.dart b/packages/flutter/test/material/flexible_space_bar_test.dart index f8fc07d6c1..e6fef3fa31 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -141,7 +141,7 @@ void main() { delegate: SliverChildListDelegate( [ for (int i = 0; i < 50; i++) - Container( + SizedBox( height: 200, child: Center(child: Text('Item $i')), ), diff --git a/packages/flutter/test/material/floating_action_button_location_test.dart b/packages/flutter/test/material/floating_action_button_location_test.dart index 67955a895e..09e3791c54 100644 --- a/packages/flutter/test/material/floating_action_button_location_test.dart +++ b/packages/flutter/test/material/floating_action_button_location_test.dart @@ -624,9 +624,9 @@ void main() { data: data, child: Scaffold( resizeToAvoidBottomInset: resizeToAvoidBottomInset, - bottomSheet: bottomSheet ? Container( + bottomSheet: bottomSheet ? const SizedBox( height: 100, - child: const Center(child: Text('BottomSheet')), + child: Center(child: Text('BottomSheet')), ) : null, appBar: appBar ? AppBar(title: const Text('Demo')) : null, bottomNavigationBar: bottomNavigationBar ? BottomNavigationBar( diff --git a/packages/flutter/test/material/ink_paint_test.dart b/packages/flutter/test/material/ink_paint_test.dart index b6029fb2e8..878578c60b 100644 --- a/packages/flutter/test/material/ink_paint_test.dart +++ b/packages/flutter/test/material/ink_paint_test.dart @@ -45,7 +45,7 @@ void main() { textDirection: TextDirection.ltr, child: Material( child: Center( - child: Container( + child: SizedBox( width: 200.0, height: 60.0, child: InkWell( @@ -94,7 +94,7 @@ void main() { textDirection: TextDirection.ltr, child: Material( child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: InkWell( @@ -267,7 +267,7 @@ void main() { textDirection: TextDirection.ltr, child: Material( child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: InkWell( @@ -358,7 +358,7 @@ void main() { textDirection: TextDirection.ltr, child: Material( child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: InkWell( @@ -394,7 +394,7 @@ void main() { textDirection: TextDirection.ltr, child: Material( child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: InkWell( diff --git a/packages/flutter/test/material/ink_well_test.dart b/packages/flutter/test/material/ink_well_test.dart index 9d44d343c7..01e797ee6b 100644 --- a/packages/flutter/test/material/ink_well_test.dart +++ b/packages/flutter/test/material/ink_well_test.dart @@ -128,7 +128,7 @@ void main() { child: Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -147,7 +147,7 @@ void main() { final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); await gesture.addPointer(); addTearDown(gesture.removePointer); - await gesture.moveTo(tester.getCenter(find.byType(Container))); + await gesture.moveTo(tester.getCenter(find.byType(SizedBox))); await tester.pumpAndSettle(); final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); expect(inkFeatures, paints..rect(rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), color: const Color(0xff00ff00))); @@ -160,7 +160,7 @@ void main() { child: Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -184,7 +184,7 @@ void main() { final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); await gesture.addPointer(); addTearDown(gesture.removePointer); - await gesture.moveTo(tester.getCenter(find.byType(Container))); + await gesture.moveTo(tester.getCenter(find.byType(SizedBox))); await tester.pumpAndSettle(); final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); expect(inkFeatures, paints..rect(rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), color: const Color(0xff00ff00))); @@ -198,7 +198,7 @@ void main() { child: Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -235,7 +235,7 @@ void main() { child: Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -278,7 +278,7 @@ void main() { child: Center( child: Focus( focusNode: focusNode, - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -316,7 +316,7 @@ void main() { child: Center( child: Focus( focusNode: focusNode, - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -354,7 +354,7 @@ void main() { child: Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkResponse( @@ -383,7 +383,7 @@ void main() { child: Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -573,9 +573,9 @@ void main() { addAutomaticKeepAlives: keepAlive, dragStartBehavior: DragStartBehavior.down, children: [ - Container(height: 500.0, child: InkWell(onTap: () {}, child: const Placeholder())), - Container(height: 500.0), - Container(height: 500.0), + SizedBox(height: 500.0, child: InkWell(onTap: () {}, child: const Placeholder())), + const SizedBox(height: 500.0), + const SizedBox(height: 500.0), ], ), ), @@ -721,7 +721,7 @@ void main() { Material( child: Directionality( textDirection: TextDirection.ltr, - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( @@ -730,7 +730,7 @@ void main() { onLongPress: () {}, onHover: (bool value) { hovering = value; }, focusNode: focusNode, - child: Container(key: childKey), + child: SizedBox(key: childKey), ), ), ), @@ -749,13 +749,13 @@ void main() { Material( child: Directionality( textDirection: TextDirection.ltr, - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( focusNode: focusNode, onHover: (bool value) { hovering = value; }, - child: Container(key: childKey), + child: SizedBox(key: childKey), ), ), ), @@ -790,7 +790,7 @@ void main() { key: middleKey, child: paddedInkWell( key: innerKey, - child: Container(width: 50, height: 50), + child: const SizedBox(width: 50, height: 50), ), ), ), @@ -852,7 +852,7 @@ void main() { textDirection: TextDirection.ltr, child: Align( alignment: Alignment.topLeft, - child: Container( + child: SizedBox( width: 200, height: 100, child: Row( @@ -863,7 +863,7 @@ void main() { key: innerKey, ), ), - Container(), + const SizedBox(), ], ), ), @@ -885,7 +885,7 @@ void main() { textDirection: TextDirection.ltr, child: Align( alignment: Alignment.topLeft, - child: Container( + child: SizedBox( width: 200, height: 100, child: Row( @@ -944,7 +944,7 @@ void main() { key: middleKey, child: paddedInkWell( key: innerKey, - child: Container(width: 50, height: 50), + child: const SizedBox(width: 50, height: 50), ), ), ), @@ -974,19 +974,19 @@ void main() { child: Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( key: parentKey, onTap: () {}, child: Center( - child: Container( + child: SizedBox( width: 100, height: 50, child: Row( children: [ - Container( + SizedBox( width: 50, height: 50, child: InkWell( @@ -994,7 +994,7 @@ void main() { onTap: () {}, ), ), - Container( + SizedBox( width: 50, height: 50, child: InkWell( @@ -1071,19 +1071,19 @@ void main() { textDirection: TextDirection.ltr, child: Align( alignment: Alignment.topLeft, - child: Container( + child: SizedBox( width: leftWidth+rightWidth, height: 100, child: Row( children: [ - Container( + SizedBox( width: leftWidth, height: 100, child: InkWell( key: leftKey, onTap: () {}, child: Center( - child: Container( + child: SizedBox( width: leftWidth, height: 50, child: leftChild, @@ -1091,14 +1091,14 @@ void main() { ), ), ), - Container( + SizedBox( width: rightWidth, height: 100, child: InkWell( key: rightKey, onTap: () {}, child: Center( - child: Container( + child: SizedBox( width: leftWidth, height: 50, child: rightChild, @@ -1176,13 +1176,13 @@ void main() { child: GestureDetector( onHorizontalDragStart: (_) {}, child: Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: InkWell( onTap: () {}, child: Center( - child: Container( + child: SizedBox( width: 50, height: 50, child: InkWell( diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 11ad7b6194..547a16dba7 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -1330,8 +1330,8 @@ void main() { buildInputDecorator( // isEmpty: false (default) // isFocused: false (default) - decoration: InputDecoration( - prefix: Container( + decoration: const InputDecoration( + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -1374,9 +1374,9 @@ void main() { buildInputDecorator( // isEmpty: false (default) // isFocused: false (default) - decoration: InputDecoration( - border: const OutlineInputBorder(), - prefix: Container( + decoration: const InputDecoration( + border: OutlineInputBorder(), + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -1905,8 +1905,8 @@ void main() { buildInputDecorator( // isEmpty: false (default) // isFocused: false (default) - decoration: InputDecoration( - prefix: Container( + decoration: const InputDecoration( + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -1934,8 +1934,8 @@ void main() { buildInputDecorator( // isEmpty: false (default) // isFocused: false (default) - decoration: InputDecoration( - prefix: Container( + decoration: const InputDecoration( + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -1963,8 +1963,8 @@ void main() { buildInputDecorator( // isEmpty: false (default) // isFocused: false (default) - decoration: InputDecoration( - prefix: Container( + decoration: const InputDecoration( + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -1995,9 +1995,9 @@ void main() { // isEmpty: false (default) // isFocused: false (default) expands: true, - decoration: InputDecoration( - border: const OutlineInputBorder(), - prefix: Container( + decoration: const InputDecoration( + border: OutlineInputBorder(), + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -2026,9 +2026,9 @@ void main() { // isEmpty: false (default) // isFocused: false (default) expands: true, - decoration: InputDecoration( - border: const OutlineInputBorder(), - prefix: Container( + decoration: const InputDecoration( + border: OutlineInputBorder(), + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -2059,9 +2059,9 @@ void main() { // isEmpty: false (default) // isFocused: false (default) expands: true, - decoration: InputDecoration( - border: const OutlineInputBorder(), - prefix: Container( + decoration: const InputDecoration( + border: OutlineInputBorder(), + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -2090,9 +2090,9 @@ void main() { // isEmpty: false (default) // isFocused: false (default) expands: true, - decoration: InputDecoration( - border: const OutlineInputBorder(), - prefix: Container( + decoration: const InputDecoration( + border: OutlineInputBorder(), + prefix: SizedBox( key: pKey, height: 100, width: 10, @@ -4109,7 +4109,7 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: buildInputDecorator( @@ -4132,7 +4132,7 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: SizedBox( width: 100, height: 100, child: buildInputDecorator( @@ -4260,7 +4260,7 @@ void main() { Widget getLabeledInputDecorator(FloatingLabelBehavior floatingLabelBehavior) => MaterialApp( home: Material( - child: Container( + child: SizedBox( width: 300, child: TextField( decoration: InputDecoration( @@ -4361,7 +4361,7 @@ void main() { await tester.pumpWidget(MaterialApp( home: Material( child: Center( - child: Container( + child: SizedBox( width: 200, height: 28, child: TextField( diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index 156de730a8..5e1e924551 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -72,10 +72,10 @@ void main() { child: Material( child: Center( child: ListTile( - leading: Container(key: leadingKey, width: 24.0, height: 24.0), + leading: SizedBox(key: leadingKey, width: 24.0, height: 24.0), title: const Text('title'), subtitle: hasSubtitle ? Text('subtitle', textScaleFactor: subtitleScaleFactor) : null, - trailing: Container(key: trailingKey, width: 24.0, height: 24.0), + trailing: SizedBox(key: trailingKey, width: 24.0, height: 24.0), dense: dense, isThreeLine: isThreeLine, ), diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index cd7a2da818..b71635cd95 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -232,9 +232,9 @@ void main() { }, child: null, ), - Material( + const Material( type: MaterialType.transparency, - child: Container( + child: SizedBox( width: 400.0, height: 500.0, ), diff --git a/packages/flutter/test/material/persistent_bottom_sheet_test.dart b/packages/flutter/test/material/persistent_bottom_sheet_test.dart index 3bc2a769f7..a61d54c532 100644 --- a/packages/flutter/test/material/persistent_bottom_sheet_test.dart +++ b/packages/flutter/test/material/persistent_bottom_sheet_test.dart @@ -59,10 +59,10 @@ void main() { return ListView( controller: controller, shrinkWrap: true, - children: [ - Container(height: 100.0, child: const Text('One')), - Container(height: 100.0, child: const Text('Two')), - Container(height: 100.0, child: const Text('Three')), + children: const [ + SizedBox(height: 100.0, child: Text('One')), + SizedBox(height: 100.0, child: Text('Two')), + SizedBox(height: 100.0, child: Text('Three')), ], ); }, @@ -94,10 +94,10 @@ void main() { return ListView( shrinkWrap: true, primary: false, - children: [ - Container(height: 100.0, child: const Text('One')), - Container(height: 100.0, child: const Text('Two')), - Container(height: 100.0, child: const Text('Three')), + children: const [ + SizedBox(height: 100.0, child: Text('One')), + SizedBox(height: 100.0, child: Text('Two')), + SizedBox(height: 100.0, child: Text('Three')), ], ); }); @@ -126,10 +126,10 @@ void main() { return ListView( shrinkWrap: true, primary: false, - children: [ - Container(height: 100.0, child: const Text('One')), - Container(height: 100.0, child: const Text('Two')), - Container(height: 100.0, child: const Text('Three')), + children: const [ + SizedBox(height: 100.0, child: Text('One')), + SizedBox(height: 100.0, child: Text('Two')), + SizedBox(height: 100.0, child: Text('Three')), ], ); }); @@ -165,10 +165,10 @@ void main() { return ListView( shrinkWrap: true, controller: controller, - children: [ - Container(height: 100.0, child: const Text('One')), - Container(height: 100.0, child: const Text('Two')), - Container(height: 100.0, child: const Text('Three')), + children: const [ + SizedBox(height: 100.0, child: Text('One')), + SizedBox(height: 100.0, child: Text('Two')), + SizedBox(height: 100.0, child: Text('Three')), ], ); }, @@ -319,18 +319,18 @@ void main() { return ListView( controller: controller, shrinkWrap: true, - children: [ - Container(height: 100.0, child: const Text('One')), - Container(height: 100.0, child: const Text('Two')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), - Container(height: 100.0, child: const Text('Three')), + children: const [ + SizedBox(height: 100.0, child: Text('One')), + SizedBox(height: 100.0, child: Text('Two')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), + SizedBox(height: 100.0, child: Text('Three')), ], ); }, @@ -516,10 +516,10 @@ void main() { return ListView( shrinkWrap: true, primary: false, - children: [ - Container(height: 100.0, child: const Text('One')), - Container(height: 100.0, child: const Text('Two')), - Container(height: 100.0, child: const Text('Three')), + children: const [ + SizedBox(height: 100.0, child: Text('One')), + SizedBox(height: 100.0, child: Text('Two')), + SizedBox(height: 100.0, child: Text('Three')), ], ); }, backgroundColor: color, elevation: elevation, shape: shape, clipBehavior: clipBehavior); diff --git a/packages/flutter/test/material/raw_material_button_test.dart b/packages/flutter/test/material/raw_material_button_test.dart index 9bd6bc4fb3..13aca7ea4c 100644 --- a/packages/flutter/test/material/raw_material_button_test.dart +++ b/packages/flutter/test/material/raw_material_button_test.dart @@ -241,7 +241,7 @@ void main() { RawMaterialButton( materialTapTargetSize: MaterialTapTargetSize.padded, onPressed: () { }, - child: Container( + child: SizedBox( width: 400.0, height: 400.0, child: Column( diff --git a/packages/flutter/test/material/refresh_indicator_test.dart b/packages/flutter/test/material/refresh_indicator_test.dart index a8735b3c01..f23ade4803 100644 --- a/packages/flutter/test/material/refresh_indicator_test.dart +++ b/packages/flutter/test/material/refresh_indicator_test.dart @@ -63,7 +63,7 @@ void main() { onRefresh: refresh, child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Container( + child: SizedBox( width: 600.0, child: ListView( physics: const AlwaysScrollableScrollPhysics(), diff --git a/packages/flutter/test/material/reorderable_list_test.dart b/packages/flutter/test/material/reorderable_list_test.dart index 7927b961dd..f0e16d4f9c 100644 --- a/packages/flutter/test/material/reorderable_list_test.dart +++ b/packages/flutter/test/material/reorderable_list_test.dart @@ -1276,7 +1276,7 @@ void main() { await tester.pumpWidget(MaterialApp( home: ReorderableListView.builder( itemBuilder: (BuildContext context, int index) { - return Container( + return SizedBox( key: ValueKey(items[index]), height: 100, child: ReorderableDragStartListener( @@ -1350,7 +1350,7 @@ class _StatefulState extends State<_Stateful> { @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 48.0, height: 48.0, child: Material( diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 1648f9139a..ffe288b4c0 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -949,7 +949,7 @@ void main() { ), ), ], - drawer: Container( + drawer: SizedBox( key: drawer, width: 204.0, child: SafeArea( @@ -1051,7 +1051,7 @@ void main() { ), ), ], - drawer: Container( + drawer: SizedBox( key: drawer, width: 204.0, child: SafeArea( @@ -2108,7 +2108,7 @@ void main() { scaffoldMessenger = ScaffoldMessenger.maybeOf(context); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -2145,7 +2145,7 @@ void main() { ScaffoldMessenger.of(context); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), diff --git a/packages/flutter/test/material/scrollbar_test.dart b/packages/flutter/test/material/scrollbar_test.dart index f8391a96da..e8f35ac1bd 100644 --- a/packages/flutter/test/material/scrollbar_test.dart +++ b/packages/flutter/test/material/scrollbar_test.dart @@ -67,15 +67,15 @@ void main() { width: 300.0, child: Scrollbar( child: ListView( - children: [ - Container(height: 40.0, child: const Text('0')), - Container(height: 40.0, child: const Text('1')), - Container(height: 40.0, child: const Text('2')), - Container(height: 40.0, child: const Text('3')), - Container(height: 40.0, child: const Text('4')), - Container(height: 40.0, child: const Text('5')), - Container(height: 40.0, child: const Text('6')), - Container(height: 40.0, child: const Text('7')), + children: const [ + SizedBox(height: 40.0, child: Text('0')), + SizedBox(height: 40.0, child: Text('1')), + SizedBox(height: 40.0, child: Text('2')), + SizedBox(height: 40.0, child: Text('3')), + SizedBox(height: 40.0, child: Text('4')), + SizedBox(height: 40.0, child: Text('5')), + SizedBox(height: 40.0, child: Text('6')), + SizedBox(height: 40.0, child: Text('7')), ], ), ), @@ -101,13 +101,13 @@ void main() { testWidgets('ScrollbarPainter does not divide by zero', (WidgetTester tester) async { await tester.pumpWidget( - _buildBoilerplate(child: Container( + _buildBoilerplate(child: SizedBox( height: 200.0, width: 300.0, child: Scrollbar( child: ListView( - children: [ - Container(height: 40.0, child: const Text('0')), + children: const [ + SizedBox(height: 40.0, child: Text('0')), ], ), ), diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index 838c4efaf3..9e1323562a 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -24,7 +24,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -69,7 +69,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -115,7 +115,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -190,7 +190,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -267,7 +267,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -353,7 +353,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -437,7 +437,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -482,7 +482,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -1603,7 +1603,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -1751,7 +1751,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -1795,7 +1795,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), @@ -2344,7 +2344,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: Container( + child: const SizedBox( height: 100.0, width: 100.0, ), diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 264d8c1232..27f7e7f3e7 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -529,13 +529,13 @@ void main() { testWidgets('text field selection toolbar renders correctly inside opacity', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: Center( - child: Container( + child: SizedBox( width: 100, height: 100, - child: const Opacity( + child: Opacity( opacity: 0.5, child: TextField( decoration: InputDecoration(hintText: 'Placeholder'), @@ -2406,7 +2406,7 @@ void main() { Widget? prefix, }) { return boilerplate( - child: Container( + child: SizedBox( height: height, child: TextField( key: textFieldKey, @@ -3173,9 +3173,9 @@ void main() { testWidgets('Can align to center', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const TextField( + child: TextField( textAlign: TextAlign.center, decoration: null, ), @@ -3207,9 +3207,9 @@ void main() { testWidgets('Can align to center within center', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const Center( + child: Center( child: TextField( textAlign: TextAlign.center, decoration: null, @@ -3528,7 +3528,7 @@ void main() { await tester.pumpWidget( overlay( - child: Container( + child: SizedBox( width: 100.0, child: TextField( controller: controller, @@ -3609,7 +3609,7 @@ void main() { await tester.pumpWidget( overlay( - child: Container( + child: SizedBox( width: 100.0, child: TextField( controller: controller, @@ -8177,9 +8177,9 @@ void main() { testWidgets('Caret center position', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const TextField( + child: TextField( textAlign: TextAlign.center, decoration: null, ), @@ -8217,9 +8217,9 @@ void main() { testWidgets('Caret indexes into trailing whitespace center align', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const TextField( + child: TextField( textAlign: TextAlign.center, decoration: null, ), @@ -8836,7 +8836,7 @@ void main() { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Container( + SizedBox( width: 100.0, child: TextField( controller: controller1, @@ -8847,21 +8847,21 @@ void main() { mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Container( + SizedBox( width: 100.0, child: TextField( controller: controller2, focusNode: focusNode2, ), ), - Container( + SizedBox( width: 100.0, child: TextField( controller: controller3, focusNode: focusNode3, ), ), - Container( + SizedBox( width: 100.0, child: TextField( controller: controller4, @@ -8870,7 +8870,7 @@ void main() { ), ], ), - Container( + SizedBox( width: 100.0, child: TextField( controller: controller5, @@ -9140,7 +9140,7 @@ void main() { child: StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return Container( + return SizedBox( width: isWide ? wideWidth : narrowWidth, child: TextField( key: textFieldKey, diff --git a/packages/flutter/test/material/text_selection_toolbar_test.dart b/packages/flutter/test/material/text_selection_toolbar_test.dart index f05ed760ed..4143efd62a 100644 --- a/packages/flutter/test/material/text_selection_toolbar_test.dart +++ b/packages/flutter/test/material/text_selection_toolbar_test.dart @@ -52,6 +52,13 @@ class _CustomMaterialTextSelectionControls extends MaterialTextSelectionControls } } +class TestBox extends SizedBox { + const TestBox({Key? key}) : super(key: key, width: itemWidth, height: itemHeight); + + static const double itemHeight = 44.0; + static const double itemWidth = 100.0; +} + void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -72,17 +79,7 @@ void main() { testWidgets('puts children in an overflow menu if they overflow', (WidgetTester tester) async { late StateSetter setState; - const double height = 44.0; - const double itemWidth = 100.0; - final List children = [ - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - Container(width: itemWidth, height: height), - ]; + final List children = List.generate(7, (int i) => const TestBox()); await tester.pumpWidget( MaterialApp( @@ -102,29 +99,29 @@ void main() { ); // All children fit on the screen, so they are all rendered. - expect(find.byType(Container), findsNWidgets(children.length)); + expect(find.byType(TestBox), findsNWidgets(children.length)); expect(_findOverflowButton(), findsNothing); // Adding one more child makes the children overflow. setState(() { children.add( - Container(width: itemWidth, height: height), + const TestBox(), ); }); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(children.length - 1)); + expect(find.byType(TestBox), findsNWidgets(children.length - 1)); expect(_findOverflowButton(), findsOneWidget); // Tap the overflow button to show the overflow menu. await tester.tap(_findOverflowButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(1)); + expect(find.byType(TestBox), findsNWidgets(1)); expect(_findOverflowButton(), findsOneWidget); // Tap the overflow button again to hide the overflow menu. await tester.tap(_findOverflowButton()); await tester.pumpAndSettle(); - expect(find.byType(Container), findsNWidgets(children.length - 1)); + expect(find.byType(TestBox), findsNWidgets(children.length - 1)); expect(_findOverflowButton(), findsOneWidget); }); diff --git a/packages/flutter/test/material/time_picker_theme_test.dart b/packages/flutter/test/material/time_picker_theme_test.dart index 409dcba383..77acbb49d2 100644 --- a/packages/flutter/test/material/time_picker_theme_test.dart +++ b/packages/flutter/test/material/time_picker_theme_test.dart @@ -460,7 +460,7 @@ Material _dayPeriodMaterial(WidgetTester tester) { } Container _dayPeriodDivider(WidgetTester tester) { - return tester.widget(find.descendant(of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl'), matching: find.byType(Container)).at(1)); + return tester.widget(find.descendant(of: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_DayPeriodControl'), matching: find.byType(Container)).at(0)); } IconButton _entryModeIconButton(WidgetTester tester) { diff --git a/packages/flutter/test/rendering/viewport_test.dart b/packages/flutter/test/rendering/viewport_test.dart index 64964ed427..5c8da28f01 100644 --- a/packages/flutter/test/rendering/viewport_test.dart +++ b/packages/flutter/test/rendering/viewport_test.dart @@ -51,13 +51,13 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: ListView( controller: ScrollController(initialScrollOffset: 300.0), children: children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 100.0, width: 300.0, child: Text('Tile $i'), @@ -96,14 +96,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 300.0, width: 200.0, child: ListView( scrollDirection: Axis.horizontal, controller: ScrollController(initialScrollOffset: 300.0), children: children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 300.0, width: 100.0, child: Text('Tile $i'), @@ -142,14 +142,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: ListView( controller: ScrollController(initialScrollOffset: 300.0), reverse: true, children: children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 100.0, width: 300.0, child: Text('Tile $i'), @@ -188,7 +188,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 300.0, width: 200.0, child: ListView( @@ -196,7 +196,7 @@ void main() { reverse: true, controller: ScrollController(initialScrollOffset: 300.0), children: children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 300.0, width: 100.0, child: Text('Tile $i'), @@ -234,14 +234,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: CustomScrollView( controller: ScrollController(initialScrollOffset: 300.0), slivers: List.generate(20, (int i) { final Widget sliver = SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 100.0, child: Text('Tile $i'), ), @@ -280,7 +280,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 300.0, width: 200.0, child: CustomScrollView( @@ -288,7 +288,7 @@ void main() { controller: ScrollController(initialScrollOffset: 300.0), slivers: List.generate(20, (int i) { final Widget sliver = SliverToBoxAdapter( - child: Container( + child: SizedBox( width: 100.0, child: Text('Tile $i'), ), @@ -327,7 +327,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: CustomScrollView( @@ -335,7 +335,7 @@ void main() { reverse: true, slivers: List.generate(20, (int i) { final Widget sliver = SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 100.0, child: Text('Tile $i'), ), @@ -372,21 +372,21 @@ void main() { testWidgets('Viewport getOffsetToReveal Sliver - up - reverse growth', (WidgetTester tester) async { const Key centerKey = ValueKey('center'); const EdgeInsets padding = EdgeInsets.only(top: 22.0, bottom: 23.0); - final Widget centerSliver = SliverPadding( + const Widget centerSliver = SliverPadding( key: centerKey, padding: padding, sliver: SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 100.0, - child: const Text('Tile center'), + child: Text('Tile center'), ), ), ); - final Widget lowerItem = Container( + const Widget lowerItem = SizedBox( height: 100.0, - child: const Text('Tile lower'), + child: Text('Tile lower'), ); - final Widget lowerSliver = SliverPadding( + const Widget lowerSliver = SliverPadding( padding: padding, sliver: SliverToBoxAdapter( child: lowerItem, @@ -394,10 +394,10 @@ void main() { ); await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: CustomScrollView( @@ -429,21 +429,21 @@ void main() { testWidgets('Viewport getOffsetToReveal Sliver - left - reverse growth', (WidgetTester tester) async { const Key centerKey = ValueKey('center'); const EdgeInsets padding = EdgeInsets.only(left: 22.0, right: 23.0); - final Widget centerSliver = SliverPadding( + const Widget centerSliver = SliverPadding( key: centerKey, padding: padding, sliver: SliverToBoxAdapter( - child: Container( + child: SizedBox( width: 100.0, - child: const Text('Tile center'), + child: Text('Tile center'), ), ), ); - final Widget lowerItem = Container( + const Widget lowerItem = SizedBox( width: 100.0, - child: const Text('Tile lower'), + child: Text('Tile lower'), ); - final Widget lowerSliver = SliverPadding( + const Widget lowerSliver = SliverPadding( padding: padding, sliver: SliverToBoxAdapter( child: lowerItem, @@ -451,10 +451,10 @@ void main() { ); await tester.pumpWidget( - Directionality( + const Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: CustomScrollView( @@ -490,7 +490,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 300.0, width: 200.0, child: CustomScrollView( @@ -499,7 +499,7 @@ void main() { controller: ScrollController(initialScrollOffset: 300.0), slivers: List.generate(20, (int i) { final Widget sliver = SliverToBoxAdapter( - child: Container( + child: SizedBox( width: 100.0, child: Text('Tile $i'), ), @@ -537,7 +537,7 @@ void main() { final ScrollController controllerY = ScrollController(initialScrollOffset: 400.0); final List> children = List>.generate(10, (int y) { return List.generate(10, (int x) { - return Container( + return SizedBox( height: 100.0, width: 100.0, child: Text('$x,$y'), @@ -567,13 +567,13 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 200.0, child: ListView( controller: controllerY, children: List.generate(10, (int y) { - return Container( + return SizedBox( height: 100.0, child: ListView( scrollDirection: Axis.horizontal, @@ -694,7 +694,7 @@ void main() { group('Nested viewports (same orientation) showOnScreen', () { final List children = List.generate(10, (int i) { - return Container( + return SizedBox( height: 100.0, width: 300.0, child: Text('$i'), @@ -706,16 +706,16 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: ListView( controller: outer, children: [ - Container( + const SizedBox( height: 200.0, ), - Container( + SizedBox( height: 200.0, width: 300.0, child: ListView( @@ -723,7 +723,7 @@ void main() { children: children, ), ), - Container( + const SizedBox( height: 200.0, ), ], @@ -896,16 +896,16 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 200.0, child: ListView( controller: controllerY, children: [ - Container( + const SizedBox( height: 150.0, ), - Container( + SizedBox( height: 100.0, child: ListView( physics: const PageScrollPhysics(), // Turns off `allowImplicitScrolling` @@ -921,7 +921,7 @@ void main() { ], ), ), - Container( + const SizedBox( height: 150.0, ), ], @@ -946,16 +946,16 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 200.0, child: ListView( controller: controllerY, children: [ - Container( + const SizedBox( height: 150.0, ), - Container( + SizedBox( height: 100.0, child: CustomScrollView( physics: const PageScrollPhysics(), // Turns off `allowImplicitScrolling` @@ -981,7 +981,7 @@ void main() { ], ), ), - Container( + const SizedBox( height: 150.0, ), ], @@ -1005,12 +1005,12 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, child: ListView( controller: controller = ScrollController(initialScrollOffset: 300.0), children: children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 300.0, child: Text('Tile $i'), ); @@ -1068,7 +1068,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 600.0, child: CustomScrollView( controller: controller = ScrollController(initialScrollOffset: 300.0), @@ -1084,7 +1084,7 @@ void main() { ), ) : SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 300.0, child: Text('Tile $i'), ), @@ -1134,7 +1134,7 @@ void main() { return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 400.0, width: 400.0, child: CustomScrollView( @@ -1146,7 +1146,7 @@ void main() { ? floatingHeader : SliverToBoxAdapter( key: (i == 19) ? const Key('19') : null, - child: Container( + child: SizedBox( height: 300.0, width: 300, child: Text('Tile $i'), @@ -1437,7 +1437,7 @@ void main() { return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 400.0, width: 400.0, child: CustomScrollView( @@ -1545,14 +1545,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 300.0, child: CustomScrollView( cacheExtent: 0, controller: outerController, slivers: [ SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 300, child: CustomScrollView( controller: innerController, @@ -1580,7 +1580,7 @@ void main() { ), ); - tester.renderObject(find.widgetWithText(SizedBox, 'Tile 1', skipOffstage: false)).showOnScreen(); + tester.renderObject(find.widgetWithText(SizedBox, 'Tile 1', skipOffstage: false).first).showOnScreen(); await tester.pumpAndSettle(); // The inner viewport scrolls to reveal the 2nd tile. expect(innerController.offset, 300.0); diff --git a/packages/flutter/test/widgets/actions_test.dart b/packages/flutter/test/widgets/actions_test.dart index 3e2f4a3f78..cb6ef7d89c 100644 --- a/packages/flutter/test/widgets/actions_test.dart +++ b/packages/flutter/test/widgets/actions_test.dart @@ -425,7 +425,7 @@ void main() { }, onShowHoverHighlight: (bool value) => hovering = value, onShowFocusHighlight: (bool value) => focusing = value, - child: Container(width: 100, height: 100, key: containerKey), + child: SizedBox(width: 100, height: 100, key: containerKey), ), ), ), @@ -800,7 +800,7 @@ void main() { }, onShowHoverHighlight: supplyCallbacks ? (bool value) => hovering = value : null, onShowFocusHighlight: supplyCallbacks ? (bool value) => focusing = value : null, - child: Container(width: 100, height: 100, key: key), + child: SizedBox(width: 100, height: 100, key: key), ), ), ), diff --git a/packages/flutter/test/widgets/align_test.dart b/packages/flutter/test/widgets/align_test.dart index dba6ac98b2..90c1802cfb 100644 --- a/packages/flutter/test/widgets/align_test.dart +++ b/packages/flutter/test/widgets/align_test.dart @@ -114,10 +114,10 @@ void main() { child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Align( widthFactor: 0.5, - child: Container( + child: SizedBox( height: 100.0, width: 100.0, ), @@ -137,11 +137,11 @@ void main() { child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: const [ Align( alignment: Alignment.center, heightFactor: 0.5, - child: Container( + child: SizedBox( height: 100.0, width: 100.0, ), diff --git a/packages/flutter/test/widgets/animated_align_test.dart b/packages/flutter/test/widgets/animated_align_test.dart index 03e40cc0c6..8a54e01126 100644 --- a/packages/flutter/test/widgets/animated_align_test.dart +++ b/packages/flutter/test/widgets/animated_align_test.dart @@ -63,13 +63,13 @@ void main() { textDirection: TextDirection.ltr, child: Row( mainAxisSize: MainAxisSize.min, - children: [ + children: const [ AnimatedAlign( alignment: Alignment.center, curve: Curves.ease, widthFactor: 0.5, - duration: const Duration(milliseconds: 200), - child: Container( + duration: Duration(milliseconds: 200), + child: SizedBox( height: 100.0, width: 100.0, ), @@ -87,13 +87,13 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Column( - children: [ + children: const [ AnimatedAlign( alignment: Alignment.center, curve: Curves.ease, heightFactor: 0.5, - duration: const Duration(milliseconds: 200), - child: Container( + duration: Duration(milliseconds: 200), + child: SizedBox( height: 100.0, width: 100.0, ), @@ -112,12 +112,12 @@ void main() { textDirection: TextDirection.ltr, child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ AnimatedAlign( alignment: Alignment.center, curve: Curves.ease, - duration: const Duration(milliseconds: 200), - child: Container( + duration: Duration(milliseconds: 200), + child: SizedBox( height: 100.0, width: 100.0, ), @@ -126,7 +126,7 @@ void main() { ), ), ); - final RenderBox box = tester.renderObject(find.byType(Container)); + final RenderBox box = tester.renderObject(find.byType(SizedBox)); expect(box.size, equals(const Size(100.0, 100))); }); @@ -138,12 +138,12 @@ void main() { child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ AnimatedAlign( alignment: Alignment.center, curve: Curves.ease, - duration: const Duration(milliseconds: 200), - child: Container( + duration: Duration(milliseconds: 200), + child: SizedBox( height: 100.0, width: 100.0, ), @@ -153,7 +153,7 @@ void main() { ), ), ); - final RenderBox box = tester.renderObject(find.byType(Container)); + final RenderBox box = tester.renderObject(find.byType(SizedBox).last); expect(box.size, equals(const Size(100.0, 100))); }); } diff --git a/packages/flutter/test/widgets/automatic_keep_alive_test.dart b/packages/flutter/test/widgets/automatic_keep_alive_test.dart index 68b6b52776..fcfa123d48 100644 --- a/packages/flutter/test/widgets/automatic_keep_alive_test.dart +++ b/packages/flutter/test/widgets/automatic_keep_alive_test.dart @@ -123,7 +123,7 @@ void tests({ required bool impliedMode }) { addSemanticIndexes: false, cacheExtent: 0.0, children: generateList( - Container(height: 12.3, child: const Placeholder()), // about 50 widgets visible + const SizedBox(height: 12.3, child: Placeholder()), // about 50 widgets visible impliedMode: impliedMode, ), ), @@ -231,7 +231,7 @@ void main() { cacheExtent: 0.0, children: [ AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(0), child: Placeholder()), @@ -239,15 +239,15 @@ void main() { ]), ), ), - AutomaticKeepAlive( - child: Container( - key: const GlobalObjectKey<_LeafState>(2), + const AutomaticKeepAlive( + child: SizedBox( + key: GlobalObjectKey<_LeafState>(2), height: 400.0, ), ), - AutomaticKeepAlive( - child: Container( - key: const GlobalObjectKey<_LeafState>(3), + const AutomaticKeepAlive( + child: SizedBox( + key: GlobalObjectKey<_LeafState>(3), height: 400.0, ), ), @@ -315,7 +315,7 @@ void main() { cacheExtent: 0.0, children: [ AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(0), child: Placeholder()), @@ -324,7 +324,7 @@ void main() { ), ), AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(2), child: Placeholder()), @@ -333,7 +333,7 @@ void main() { ), ), AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(4), child: Placeholder()), @@ -371,7 +371,7 @@ void main() { cacheExtent: 0.0, children: [ AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(1), child: Placeholder()), @@ -379,7 +379,7 @@ void main() { ), ), AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(2), child: Placeholder()), @@ -388,7 +388,7 @@ void main() { ), ), AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(4), child: Placeholder()), @@ -435,7 +435,7 @@ void main() { cacheExtent: 0.0, children: [ AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(1), child: Placeholder()), @@ -444,14 +444,14 @@ void main() { ), ), AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ ]), ), ), AutomaticKeepAlive( - child: Container( + child: SizedBox( height: 400.0, child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(3), child: Placeholder()), @@ -486,7 +486,7 @@ void main() { key: GlobalObjectKey<_AlwaysKeepAliveState>(0), ); } - return Container( + return SizedBox( height: 44.0, child: Text('FooBar $index'), ); @@ -520,7 +520,7 @@ void main() { key: GlobalObjectKey<_AlwaysKeepAliveState>(index), ); } - return Container( + return SizedBox( height: 44.0, child: Text('FooBar $index'), ); @@ -573,9 +573,9 @@ class _AlwaysKeepAliveState extends State<_AlwaysKeepAlive> with AutomaticKeepAl @override Widget build(BuildContext context) { super.build(context); - return Container( + return const SizedBox( height: 48.0, - child: const Text('keep me alive'), + child: Text('keep me alive'), ); } } @@ -591,9 +591,9 @@ class AlwaysKeepAliveRenderBoxState extends State<_AlwaysKeepAlive> with Automat @override Widget build(BuildContext context) { super.build(context); - return Container( + return const SizedBox( height: 48.0, - child: const Text('keep me alive'), + child: Text('keep me alive'), ); } } diff --git a/packages/flutter/test/widgets/column_test.dart b/packages/flutter/test/widgets/column_test.dart index 03fa93e956..1e5af83c25 100644 --- a/packages/flutter/test/widgets/column_test.dart +++ b/packages/flutter/test/widgets/column_test.dart @@ -21,10 +21,10 @@ void main() { await tester.pumpWidget(Center( child: Column( key: columnKey, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0)), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + Expanded(child: SizedBox(key: child1Key, width: 100.0, height: 100.0)), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -67,10 +67,10 @@ void main() { await tester.pumpWidget(Center( child: Column( key: columnKey, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -112,9 +112,9 @@ void main() { child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), ], ), )); @@ -151,10 +151,10 @@ void main() { child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -197,10 +197,10 @@ void main() { child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -244,11 +244,11 @@ void main() { child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), - Container(key: child3Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), + SizedBox(key: child3Key, width: 100.0, height: 100.0), ], ), )); @@ -297,10 +297,10 @@ void main() { child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container(key: child0Key, width: 100.0, height: 20.0), - Container(key: child1Key, width: 100.0, height: 20.0), - Container(key: child2Key, width: 100.0, height: 20.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 20.0), + SizedBox(key: child1Key, width: 100.0, height: 20.0), + SizedBox(key: child2Key, width: 100.0, height: 20.0), ], ), )); @@ -368,13 +368,13 @@ void main() { const Key childKey = Key('childKey'); await tester.pumpWidget(Center( - child: Container( + child: SizedBox( width: 0.0, height: 0.0, child: Column( mainAxisSize: MainAxisSize.min, - children: [ - Container( + children: const [ + SizedBox( key: childKey, width: 100.0, height: 100.0, @@ -405,10 +405,10 @@ void main() { child: Column( key: columnKey, verticalDirection: VerticalDirection.up, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0)), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + Expanded(child: SizedBox(key: child1Key, width: 100.0, height: 100.0)), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -452,10 +452,10 @@ void main() { child: Column( key: columnKey, verticalDirection: VerticalDirection.up, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -498,9 +498,9 @@ void main() { key: columnKey, mainAxisAlignment: MainAxisAlignment.center, verticalDirection: VerticalDirection.up, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), ], ), )); @@ -538,10 +538,10 @@ void main() { key: columnKey, mainAxisAlignment: MainAxisAlignment.end, verticalDirection: VerticalDirection.up, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -585,10 +585,10 @@ void main() { key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, verticalDirection: VerticalDirection.up, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), ], ), )); @@ -633,11 +633,11 @@ void main() { key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceAround, verticalDirection: VerticalDirection.up, - children: [ - Container(key: child0Key, width: 100.0, height: 100.0), - Container(key: child1Key, width: 100.0, height: 100.0), - Container(key: child2Key, width: 100.0, height: 100.0), - Container(key: child3Key, width: 100.0, height: 100.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 100.0), + SizedBox(key: child1Key, width: 100.0, height: 100.0), + SizedBox(key: child2Key, width: 100.0, height: 100.0), + SizedBox(key: child3Key, width: 100.0, height: 100.0), ], ), )); @@ -687,10 +687,10 @@ void main() { key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, verticalDirection: VerticalDirection.up, - children: [ - Container(key: child0Key, width: 100.0, height: 20.0), - Container(key: child1Key, width: 100.0, height: 20.0), - Container(key: child2Key, width: 100.0, height: 20.0), + children: const [ + SizedBox(key: child0Key, width: 100.0, height: 20.0), + SizedBox(key: child1Key, width: 100.0, height: 20.0), + SizedBox(key: child2Key, width: 100.0, height: 20.0), ], ), )); @@ -760,14 +760,14 @@ void main() { const Key childKey = Key('childKey'); await tester.pumpWidget(Center( - child: Container( + child: SizedBox( width: 0.0, height: 0.0, child: Column( mainAxisSize: MainAxisSize.min, verticalDirection: VerticalDirection.up, - children: [ - Container( + children: const [ + SizedBox( key: childKey, width: 100.0, height: 100.0, diff --git a/packages/flutter/test/widgets/composited_transform_test.dart b/packages/flutter/test/widgets/composited_transform_test.dart index e171feea75..16cc41b34a 100644 --- a/packages/flutter/test/widgets/composited_transform_test.dart +++ b/packages/flutter/test/widgets/composited_transform_test.dart @@ -35,7 +35,7 @@ void main() { link: linkToUse ?? link, targetAnchor: Alignment.center, followerAnchor: Alignment.center, - child: Container(key: key, height: 20.0, width: 20.0), + child: SizedBox(key: key, height: 20.0, width: 20.0), ), ), ], @@ -76,7 +76,7 @@ void main() { link: link, targetAnchor: targetAlignment, followerAnchor: followerAlignment, - child: Container(key: key, height: 20.0, width: 20.0), + child: SizedBox(key: key, height: 20.0, width: 20.0), ), ), ], @@ -119,7 +119,7 @@ void main() { angle: 1.0, // radians child: CompositedTransformTarget( link: link, - child: Container(key: key1, width: 80.0, height: 10.0), + child: SizedBox(key: key1, width: 80.0, height: 10.0), ), ), ), @@ -132,7 +132,7 @@ void main() { link: link, targetAnchor: targetAlignment, followerAnchor: followerAlignment, - child: Container(key: key2, width: 40.0, height: 20.0), + child: SizedBox(key: key2, width: 40.0, height: 20.0), ), ), ), @@ -184,7 +184,7 @@ void main() { angle: 1.0, // radians child: CompositedTransformTarget( link: link, - child: Container(key: key1, width: 80.0, height: 10.0), + child: SizedBox(key: key1, width: 80.0, height: 10.0), ), ), ), @@ -205,7 +205,7 @@ void main() { link: link, targetAnchor: targetAlignment, followerAnchor: followerAlignment, - child: Container(key: key2, width: 40.0, height: 20.0), + child: SizedBox(key: key2, width: 40.0, height: 20.0), ), ), ), @@ -262,7 +262,7 @@ void main() { top: 456.0, child: CompositedTransformTarget( link: link, - child: Container(key: key1, height: 10.0, width: 10.0), + child: SizedBox(key: key1, height: 10.0, width: 10.0), ), ), CompositedTransformFollower( @@ -271,7 +271,7 @@ void main() { key: key2, behavior: HitTestBehavior.opaque, onTap: () { tapped = true; }, - child: Container(key: key3, height: 2.0, width: 2.0), + child: SizedBox(key: key3, height: 2.0, width: 2.0), ), ), ], diff --git a/packages/flutter/test/widgets/dismissible_test.dart b/packages/flutter/test/widgets/dismissible_test.dart index 2d58f5465b..e2becd4a6e 100644 --- a/packages/flutter/test/widgets/dismissible_test.dart +++ b/packages/flutter/test/widgets/dismissible_test.dart @@ -46,7 +46,7 @@ Widget buildTest({ ? {} : {DismissDirection.startToEnd: startToEndThreshold}, crossAxisEndOffset: crossAxisEndOffset, - child: Container( + child: SizedBox( width: itemExtent, height: itemExtent, child: Text(item.toString()), @@ -574,7 +574,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 1000.0, child: Column( @@ -755,7 +755,7 @@ void main() { background: background, dismissThresholds: const {}, crossAxisEndOffset: crossAxisEndOffset, - child: Container( + child: SizedBox( width: itemExtent, height: itemExtent, child: Text(1.toString()), diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index d7bf95a606..7366e68038 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -30,7 +30,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onMove: (_) => moveCount++, onAccept: accepted.add, @@ -103,7 +103,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 1')); + return const SizedBox(height: 100.0, child: Text('Target 1')); }, onLeave: (int? data) { if (data != null) { @@ -113,7 +113,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 2')); + return const SizedBox(height: 100.0, child: Text('Target 2')); }, onLeave: (int? data) { if (data != null) { @@ -178,7 +178,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 1')); + return const SizedBox(height: 100.0, child: Text('Target 1')); }, onLeave: (Object? data) { if (data is int) { @@ -188,7 +188,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 2')); + return const SizedBox(height: 100.0, child: Text('Target 2')); }, onLeave: (Object? data) { if (data is int) { @@ -255,7 +255,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 1')); + return const SizedBox(height: 100.0, child: Text('Target 1')); }, onMove: (DragTargetDetails details) { targetMoveCount['Target 1'] = @@ -264,7 +264,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 2')); + return const SizedBox(height: 100.0, child: Text('Target 2')); }, onMove: (DragTargetDetails details) { targetMoveCount['Target 2'] = @@ -328,7 +328,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 1')); + return const SizedBox(height: 100.0, child: Text('Target 1')); }, onMove: (DragTargetDetails details) { if (details.data is int) { @@ -339,7 +339,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target 2')); + return const SizedBox(height: 100.0, child: Text('Target 2')); }, onMove: (DragTargetDetails details) { if (details.data is int) { @@ -1163,7 +1163,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -1235,9 +1235,9 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container( + return const SizedBox( height: 100.0, - child: const Text('Target'), + child: Text('Target'), ); }, onWillAccept: (int? data) => false, @@ -1311,10 +1311,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container( - height: 100.0, - child: const Text('Target'), - ); + return const SizedBox(height: 100.0, child: Text('Target')); }, onWillAccept: (int? data) => false, onAccept: accepted.add, @@ -1364,10 +1361,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container( - height: 100.0, - child: const Text('Target'), - ); + return const SizedBox(height: 100.0, child: Text('Target')); }, onWillAccept: (int? data) => false, onAccept: accepted.add, @@ -1434,7 +1428,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container( + return SizedBox( height: 100.0, child: rejects.isNotEmpty ? const Text('Rejected') @@ -1492,7 +1486,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container( + return SizedBox( height: 100.0, child: rejects.isNotEmpty ? const Text('Rejected') @@ -1577,9 +1571,9 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container( + return const SizedBox( height: 100.0, - child: const Text('Target'), + child: Text('Target'), ); }, onWillAccept: (int? data) => false, @@ -1649,7 +1643,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -1790,7 +1784,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -1863,10 +1857,10 @@ void main() { children: [ DragTarget( builder: (BuildContext context, List data, List rejects) { - return IgnorePointer( - child: Container( + return const IgnorePointer( + child: SizedBox( height: 100.0, - child: const Text('Target1'), + child: Text('Target1'), ), ); }, @@ -1875,10 +1869,10 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return IgnorePointer( - child: Container( + return const IgnorePointer( + child: SizedBox( height: 100.0, - child: const Text('Target2'), + child: Text('Target2'), ), ); }, @@ -1992,10 +1986,10 @@ void main() { children: [ DragTarget( builder: (BuildContext context, List data, List rejects) { - return IgnorePointer( - child: Container( + return const IgnorePointer( + child: SizedBox( height: 100.0, - child: const Text('Target1'), + child: Text('Target1'), ), ); }, onAccept: acceptedDragTargetDatas.add, @@ -2003,10 +1997,10 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return IgnorePointer( - child: Container( + return const IgnorePointer( + child: SizedBox( height: 100.0, - child: const Text('Target2'), + child: Text('Target2'), ), ); }, @@ -2058,7 +2052,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -2317,7 +2311,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -2347,7 +2341,7 @@ void main() { children: [ DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -2427,7 +2421,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -2512,7 +2506,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, @@ -2696,7 +2690,7 @@ void main() { navigatorKey: rootNavigatorKey, home: Column( children: [ - Container( + SizedBox( height: 200.0, child: Navigator( key: childNavigatorKey, @@ -2718,8 +2712,8 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container( - height: 300.0, child: const Center(child: Text('Target 1')), + return const SizedBox( + height: 300.0, child: Center(child: Text('Target 1')), ); }, ), @@ -2765,7 +2759,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, ), @@ -2801,7 +2795,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, ), @@ -2837,7 +2831,7 @@ void main() { ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onWillAccept: (int? data) { @@ -3033,11 +3027,11 @@ void main() { await tester.pumpWidget( MaterialApp( home: Column( - children: [ + children: const [ Draggable( hitTestBehavior: hitTestBehavior, - feedback: Container(height: 50.0, child: const Text('Draggable')), - child: Container(height: 50.0, child: const Text('Target')), + feedback: SizedBox(height: 50.0, child: Text('Draggable')), + child: SizedBox(height: 50.0, child: Text('Target')), ), ], ), @@ -3058,7 +3052,7 @@ void main() { hitTestBehavior: hitTestBehavior, builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, ), ], @@ -3139,7 +3133,7 @@ Future _testChildAnchorFeedbackPosition({ required WidgetTester tester, do ), DragTarget( builder: (BuildContext context, List data, List rejects) { - return Container(height: 100.0, child: const Text('Target')); + return const SizedBox(height: 100.0, child: Text('Target')); }, onAccept: accepted.add, onAcceptWithDetails: acceptedDetails.add, diff --git a/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart b/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart index 1ff6d421ea..3f14610b89 100644 --- a/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart +++ b/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart @@ -49,7 +49,7 @@ void main() { await tester.pumpWidget(MaterialApp( home: Center( - child: Container( + child: SizedBox( height: 300.0, child: ListView( controller: scrollController, @@ -61,7 +61,7 @@ void main() { style: textStyle, cursorColor: cursorColor, ), - Container( + const SizedBox( height: 350.0, ), ], @@ -88,12 +88,12 @@ void main() { await tester.pumpWidget(MaterialApp( home: Center( - child: Container( + child: SizedBox( height: 300.0, child: ListView( controller: scrollController, children: [ - Container( + const SizedBox( height: 200.0, ), EditableText( @@ -104,7 +104,7 @@ void main() { style: textStyle, cursorColor: cursorColor, ), - Container( + const SizedBox( height: 850.0, ), ], @@ -134,12 +134,12 @@ void main() { await tester.pumpWidget(MaterialApp( home: Center( - child: Container( + child: SizedBox( height: 300.0, child: ListView( controller: scrollController, children: [ - Container( + const SizedBox( height: 350.0, ), EditableText( @@ -149,7 +149,7 @@ void main() { style: textStyle, cursorColor: cursorColor, ), - Container( + const SizedBox( height: 350.0, ), ], @@ -183,13 +183,13 @@ void main() { await tester.pumpWidget(MaterialApp( home: Center( - child: Container( + child: SizedBox( height: 300.0, child: ListView( physics: const NoImplicitScrollPhysics(), controller: scrollController, children: [ - Container( + const SizedBox( height: 350.0, ), EditableText( @@ -199,7 +199,7 @@ void main() { style: textStyle, cursorColor: cursorColor, ), - Container( + const SizedBox( height: 350.0, ), ], @@ -281,7 +281,7 @@ void main() { await tester.pumpWidget(MaterialApp( home: Center( - child: Container( + child: SizedBox( height: 300.0, child: ListView( controller: scrollController, @@ -333,12 +333,12 @@ void main() { await tester.pumpWidget(MaterialApp( home: Align( alignment: Alignment.bottomCenter, - child: Container( + child: SizedBox( height: 300.0, child: ListView( controller: scrollController, children: [ - Container( + const SizedBox( key: container, height: 200.0, ), @@ -350,7 +350,7 @@ void main() { style: textStyle, cursorColor: cursorColor, ), - Container( + const SizedBox( height: 400.0, ), ], @@ -406,7 +406,7 @@ void main() { ), ) : SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 100.0, child: Text('Tile $i'), ), @@ -469,7 +469,7 @@ void main() { ), ) : SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 100.0, child: Text('Tile $i'), ), diff --git a/packages/flutter/test/widgets/ensure_visible_test.dart b/packages/flutter/test/widgets/ensure_visible_test.dart index ec1f3e0837..9b943af641 100644 --- a/packages/flutter/test/widgets/ensure_visible_test.dart +++ b/packages/flutter/test/widgets/ensure_visible_test.dart @@ -22,14 +22,14 @@ Widget buildSingleChildScrollView(Axis scrollDirection, { bool reverse = false } reverse: reverse, child: ListBody( mainAxis: scrollDirection, - children: [ - Container(key: const ValueKey(0), width: 200.0, height: 200.0), - Container(key: const ValueKey(1), width: 200.0, height: 200.0), - Container(key: const ValueKey(2), width: 200.0, height: 200.0), - Container(key: const ValueKey(3), width: 200.0, height: 200.0), - Container(key: const ValueKey(4), width: 200.0, height: 200.0), - Container(key: const ValueKey(5), width: 200.0, height: 200.0), - Container(key: const ValueKey(6), width: 200.0, height: 200.0), + children: const [ + SizedBox(key: ValueKey(0), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(1), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(2), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(3), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(4), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(5), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(6), width: 200.0, height: 200.0), ], ), ), @@ -50,14 +50,14 @@ Widget buildListView(Axis scrollDirection, { bool reverse = false, bool shrinkWr reverse: reverse, addSemanticIndexes: false, shrinkWrap: shrinkWrap, - children: [ - Container(key: const ValueKey(0), width: 200.0, height: 200.0), - Container(key: const ValueKey(1), width: 200.0, height: 200.0), - Container(key: const ValueKey(2), width: 200.0, height: 200.0), - Container(key: const ValueKey(3), width: 200.0, height: 200.0), - Container(key: const ValueKey(4), width: 200.0, height: 200.0), - Container(key: const ValueKey(5), width: 200.0, height: 200.0), - Container(key: const ValueKey(6), width: 200.0, height: 200.0), + children: const [ + SizedBox(key: ValueKey(0), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(1), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(2), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(3), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(4), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(5), width: 200.0, height: 200.0), + SizedBox(key: ValueKey(6), width: 200.0, height: 200.0), ], ), ), @@ -187,10 +187,10 @@ void main() { child: SingleChildScrollView( child: ListBody( children: [ - Container(height: 200.0), - Container(height: 200.0), - Container(height: 200.0), - Container( + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), + SizedBox( height: 200.0, child: Center( child: Transform( @@ -204,9 +204,9 @@ void main() { ), ), ), - Container(height: 200.0), - Container(height: 200.0), - Container(height: 200.0), + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), ], ), ), @@ -230,9 +230,9 @@ void main() { final List rows = List.generate( 7, (int y) => Row( - children: List.generate( + children: List.generate( 7, - (int x) => Container(key: ValueKey('$x, $y'), width: 200.0, height: 200.0,), + (int x) => SizedBox(key: ValueKey('$x, $y'), width: 200.0, height: 200.0,), ), ), ); @@ -519,10 +519,10 @@ void main() { height: 400.0, child: ListView( children: [ - Container(height: 200.0), - Container(height: 200.0), - Container(height: 200.0), - Container( + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), + SizedBox( height: 200.0, child: Center( child: Transform( @@ -536,9 +536,9 @@ void main() { ), ), ), - Container(height: 200.0), - Container(height: 200.0), - Container(height: 200.0), + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), + const SizedBox(height: 200.0), ], ), ), @@ -722,20 +722,20 @@ void main() { return Viewport( offset: offset, center: const ValueKey('center'), - slivers: [ - SliverToBoxAdapter(child: Container(key: const ValueKey(-6), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(-5), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(-4), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(-3), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(-2), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(-1), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(0), width: 200.0, height: 200.0), key: const ValueKey('center')), - SliverToBoxAdapter(child: Container(key: const ValueKey(1), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(2), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(3), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(4), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(5), width: 200.0, height: 200.0)), - SliverToBoxAdapter(child: Container(key: const ValueKey(6), width: 200.0, height: 200.0)), + slivers: const [ + SliverToBoxAdapter(child: SizedBox(key: ValueKey(-6), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(-5), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(-4), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(-3), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(-2), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(-1), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(0), width: 200.0, height: 200.0), key: ValueKey('center')), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(1), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(2), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(3), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(4), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(5), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: SizedBox(key: ValueKey(6), width: 200.0, height: 200.0)), ], ); }, diff --git a/packages/flutter/test/widgets/fitted_box_test.dart b/packages/flutter/test/widgets/fitted_box_test.dart index 79437afd2f..35e3871ab5 100644 --- a/packages/flutter/test/widgets/fitted_box_test.dart +++ b/packages/flutter/test/widgets/fitted_box_test.dart @@ -13,11 +13,11 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: SizedBox( width: 200.0, child: FittedBox( key: outside, - child: Container( + child: SizedBox( key: inside, width: 100.0, height: 50.0, @@ -48,12 +48,12 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: SizedBox( width: 200.0, height: 200.0, child: FittedBox( key: outside, - child: Container( + child: SizedBox( key: inside, width: 100.0, height: 50.0, @@ -83,13 +83,13 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: SizedBox( width: 200.0, height: 200.0, child: FittedBox( key: outside, fit: BoxFit.cover, - child: Container( + child: SizedBox( key: inside, width: 100.0, height: 50.0, @@ -139,14 +139,14 @@ void main() { Directionality( textDirection: TextDirection.rtl, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.bottomEnd, - child: Container( + child: SizedBox( key: inside, width: 10.0, height: 10.0, @@ -180,14 +180,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.bottomEnd, - child: Container( + child: SizedBox( key: inside, width: 10.0, height: 10.0, @@ -221,14 +221,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.center, - child: Container( + child: SizedBox( key: inside, width: 10.0, height: 10.0, @@ -262,14 +262,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.center, - child: Container( + child: SizedBox( key: inside, width: 30.0, height: 10.0, @@ -303,14 +303,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: FittedBox( key: outside, fit: BoxFit.fill, alignment: AlignmentDirectional.center, - child: Container( + child: SizedBox( key: inside, width: 30.0, height: 10.0, @@ -493,12 +493,12 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: SizedBox( width: 200.0, child: FittedBox( key: outside, fit: BoxFit.scaleDown, - child: Container( + child: SizedBox( key: inside, width: 100.0, height: 50.0, @@ -522,12 +522,12 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: SizedBox( width: 200.0, child: FittedBox( key: outside, fit: BoxFit.scaleDown, - child: Container( + child: SizedBox( key: inside, width: 400.0, height: 200.0, @@ -550,12 +550,12 @@ void main() { final Key outside = UniqueKey(); final Widget scaleDownWidget = Center( - child: Container( + child: SizedBox( width: 200.0, child: FittedBox( key: outside, fit: BoxFit.scaleDown, - child: Container( + child: const SizedBox( width: 100.0, height: 50.0, ), @@ -564,11 +564,11 @@ void main() { ); final Widget coverWidget = Center( - child: Container( + child: SizedBox( width: 200.0, child: FittedBox( key: outside, - child: Container( + child: const SizedBox( width: 100.0, height: 50.0, ), diff --git a/packages/flutter/test/widgets/flex_test.dart b/packages/flutter/test/widgets/flex_test.dart index 15b5dca3a0..7ed9d25229 100644 --- a/packages/flutter/test/widgets/flex_test.dart +++ b/packages/flutter/test/widgets/flex_test.dart @@ -65,16 +65,16 @@ void main() { // both of these cases have failed in the past due to floating point issues await tester.pumpWidget( Center( - child: Container( + child: SizedBox( height: 400.0, child: Column( - children: [ - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), + children: const [ + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), ], ), ), @@ -82,16 +82,16 @@ void main() { ); await tester.pumpWidget( Center( - child: Container( + child: SizedBox( height: 199.0, child: Column( - children: [ - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), - Expanded(child: Container()), + children: const [ + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), + Expanded(child: SizedBox()), ], ), ), diff --git a/packages/flutter/test/widgets/focus_manager_test.dart b/packages/flutter/test/widgets/focus_manager_test.dart index 2499236b68..d445a49433 100644 --- a/packages/flutter/test/widgets/focus_manager_test.dart +++ b/packages/flutter/test/widgets/focus_manager_test.dart @@ -74,14 +74,14 @@ void main() { padding: const EdgeInsets.all(8.0), child: Column( children: [ - Focus(focusNode: focusNode1, child: Container(width: 200, height: 100),), + Focus(focusNode: focusNode1, child: const SizedBox(width: 200, height: 100),), Transform.translate( offset: const Offset(10, 20), child: Transform.scale( scale: 0.33, child: Transform.rotate( angle: math.pi, - child: Focus(focusNode: focusNode2, child: Container(width: 200, height: 100)), + child: Focus(focusNode: focusNode2, child: const SizedBox(width: 200, height: 100)), ), ), ), diff --git a/packages/flutter/test/widgets/focus_traversal_test.dart b/packages/flutter/test/widgets/focus_traversal_test.dart index 14e3a95d73..e4cfc56735 100644 --- a/packages/flutter/test/widgets/focus_traversal_test.dart +++ b/packages/flutter/test/widgets/focus_traversal_test.dart @@ -38,11 +38,11 @@ void main() { children: [ Focus( key: key2, - child: Container(key: key3, width: 100, height: 100), + child: SizedBox(key: key3, width: 100, height: 100), ), Focus( key: key4, - child: Container(key: key5, width: 100, height: 100), + child: SizedBox(key: key5, width: 100, height: 100), ), ], ), @@ -77,11 +77,11 @@ void main() { children: [ Focus( key: key2, - child: Container(key: key3, width: 100, height: 100), + child: SizedBox(key: key3, width: 100, height: 100), ), Focus( key: key4, - child: Container(key: key5, width: 100, height: 100), + child: SizedBox(key: key5, width: 100, height: 100), ), ], ), @@ -413,11 +413,11 @@ void main() { children: [ Focus( key: key2, - child: Container(key: key3, width: 100, height: 100), + child: SizedBox(key: key3, width: 100, height: 100), ), Focus( key: key4, - child: Container(key: key5, width: 100, height: 100), + child: SizedBox(key: key5, width: 100, height: 100), ), ], ), @@ -849,13 +849,13 @@ void main() { FocusTraversalOrder( order: const NumericFocusOrder(2), child: Focus( - child: Container(key: key1, width: 100, height: 100), + child: SizedBox(key: key1, width: 100, height: 100), ), ), FocusTraversalOrder( order: const NumericFocusOrder(1), child: Focus( - child: Container(key: key2, width: 100, height: 100), + child: SizedBox(key: key2, width: 100, height: 100), ), ), ], @@ -1225,12 +1225,12 @@ void main() { Focus( debugLabel: 'upperLeft', onFocusChange: (bool focus) => focusUpperLeft = focus, - child: Container(width: 100, height: 100, key: upperLeftKey), + child: SizedBox(width: 100, height: 100, key: upperLeftKey), ), Focus( debugLabel: 'upperRight', onFocusChange: (bool focus) => focusUpperRight = focus, - child: Container(width: 100, height: 100, key: upperRightKey), + child: SizedBox(width: 100, height: 100, key: upperRightKey), ), ], ), @@ -1239,12 +1239,12 @@ void main() { Focus( debugLabel: 'lowerLeft', onFocusChange: (bool focus) => focusLowerLeft = focus, - child: Container(width: 100, height: 100, key: lowerLeftKey), + child: SizedBox(width: 100, height: 100, key: lowerLeftKey), ), Focus( debugLabel: 'lowerRight', onFocusChange: (bool focus) => focusLowerRight = focus, - child: Container(width: 100, height: 100, key: lowerRightKey), + child: SizedBox(width: 100, height: 100, key: lowerRightKey), ), ], ), @@ -1356,7 +1356,7 @@ void main() { return Focus( debugLabel: keys[index].toString(), onFocusChange: (bool isFocused) => focus[index] = isFocused, - child: Container(width: 100, height: 100, key: keys[index]), + child: SizedBox(width: 100, height: 100, key: keys[index]), ); } @@ -1498,11 +1498,11 @@ void main() { children: [ Focus( debugLabel: 'upperLeft', - child: Container(width: 100, height: 100, key: upperLeftKey), + child: SizedBox(width: 100, height: 100, key: upperLeftKey), ), Focus( debugLabel: 'upperRight', - child: Container(width: 100, height: 100, key: upperRightKey), + child: SizedBox(width: 100, height: 100, key: upperRightKey), ), ], ), @@ -1510,7 +1510,7 @@ void main() { children: [ Focus( debugLabel: 'lowerLeft', - child: Container(width: 100, height: 100, key: lowerLeftKey), + child: SizedBox(width: 100, height: 100, key: lowerLeftKey), ), const Focus( debugLabel: 'lowerRight', @@ -1613,11 +1613,11 @@ void main() { Focus( autofocus: true, debugLabel: 'upperLeft', - child: Container(width: 100, height: 100, key: upperLeftKey), + child: SizedBox(width: 100, height: 100, key: upperLeftKey), ), Focus( debugLabel: 'upperRight', - child: Container(width: 100, height: 100, key: upperRightKey), + child: SizedBox(width: 100, height: 100, key: upperRightKey), ), ], ), @@ -1625,11 +1625,11 @@ void main() { children: [ Focus( debugLabel: 'lowerLeft', - child: Container(width: 100, height: 100, key: lowerLeftKey), + child: SizedBox(width: 100, height: 100, key: lowerLeftKey), ), Focus( debugLabel: 'lowerRight', - child: Container(width: 100, height: 100, key: lowerRightKey), + child: SizedBox(width: 100, height: 100, key: lowerRightKey), ), ], ), @@ -1909,7 +1909,7 @@ void main() { children: [ Row( children: [ - Container( + SizedBox( width: 100, height: 100, child: EditableText( @@ -1922,7 +1922,7 @@ void main() { style: const TextStyle(), ), ), - Container( + SizedBox( width: 100, height: 100, child: EditableText( @@ -1938,7 +1938,7 @@ void main() { ), Row( children: [ - Container( + SizedBox( width: 100, height: 100, child: EditableText( @@ -1950,7 +1950,7 @@ void main() { style: const TextStyle(), ), ), - Container( + SizedBox( width: 100, height: 100, child: EditableText( diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index 731fed8a06..19bc675c96 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -1030,7 +1030,7 @@ void main() { await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 100, child: CustomScrollView( controller: ScrollController(), diff --git a/packages/flutter/test/widgets/gesture_detector_test.dart b/packages/flutter/test/widgets/gesture_detector_test.dart index a040543016..72f67d2c94 100644 --- a/packages/flutter/test/widgets/gesture_detector_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_test.dart @@ -155,7 +155,7 @@ void main() { color: const Color(0xFF00FF00), ), ), - Container( + SizedBox( width: 100.0, height: 100.0, child: GestureDetector( diff --git a/packages/flutter/test/widgets/grid_view_layout_test.dart b/packages/flutter/test/widgets/grid_view_layout_test.dart index 5486a9fbd0..221b96080b 100644 --- a/packages/flutter/test/widgets/grid_view_layout_test.dart +++ b/packages/flutter/test/widgets/grid_view_layout_test.dart @@ -18,7 +18,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 200.0, child: GridView.extent( maxCrossAxisExtent: 100.0, @@ -47,7 +47,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 200.0, child: GridView.extent( maxCrossAxisExtent: 60.0, diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 40c3971acd..7ae6a05d2a 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -43,7 +43,7 @@ final Map routes = { Card(child: Hero( tag: 'a', transitionOnUserGestures: transitionFromUserGestures, - child: Container(height: 100.0, width: 100.0, key: firstKey), + child: SizedBox(height: 100.0, width: 100.0, key: firstKey), )), const SizedBox(height: 100.0, width: 100.0), TextButton( @@ -73,7 +73,7 @@ final Map routes = { Card(child: Hero( tag: 'a', transitionOnUserGestures: transitionFromUserGestures, - child: Container(height: 150.0, width: 150.0, key: secondKey), + child: SizedBox(height: 150.0, width: 150.0, key: secondKey), )), const SizedBox(height: 150.0, width: 150.0), TextButton( @@ -102,7 +102,7 @@ final Map routes = { child: Hero( tag: 'a', transitionOnUserGestures: transitionFromUserGestures, - child: Container(height: 150.0, width: 150.0, key: secondKey), + child: SizedBox(height: 150.0, width: 150.0, key: secondKey), ), ), ), @@ -123,7 +123,7 @@ final Map routes = { child: Hero( tag: 'a', transitionOnUserGestures: transitionFromUserGestures, - child: Container(height: 150.0, width: 150.0, key: simpleKey), + child: SizedBox(height: 150.0, width: 150.0, key: simpleKey), ), ), ), @@ -137,7 +137,7 @@ class ThreeRoute extends MaterialPageRoute { child: ListView( children: [ const SizedBox(height: 200.0, width: 200.0), - Card(child: Hero(tag: 'a', child: Container(height: 200.0, width: 200.0, key: thirdKey))), + Card(child: Hero(tag: 'a', child: SizedBox(height: 200.0, width: 200.0, key: thirdKey))), const SizedBox(height: 200.0, width: 200.0), ], ), @@ -497,10 +497,10 @@ Future main() async { onTap: () { log.add('foo'); }, - child: Container( + child: const SizedBox( width: 100.0, height: 100.0, - child: const Text('foo'), + child: Text('foo'), ), ), ), @@ -515,10 +515,10 @@ Future main() async { onTap: () { log.add('bar'); }, - child: Container( + child: const SizedBox( width: 100.0, height: 150.0, - child: const Text('bar'), + child: Text('bar'), ), ), ), @@ -813,7 +813,7 @@ Future main() async { heroCardSetState = setState; return Card( child: routeIncludesHero - ? Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0)) + ? const Hero(tag: 'H', child: SizedBox(key: routeHeroKey, height: 200.0, width: 200.0)) : const SizedBox(height: 200.0, width: 200.0), ); }, @@ -836,8 +836,8 @@ Future main() async { builder: (BuildContext context) { // Navigator.push() needs context return ListView( children: [ - Card( - child: Hero(tag: 'H', child: Container(key: homeHeroKey, height: 100.0, width: 100.0)), + const Card( + child: Hero(tag: 'H', child: SizedBox(key: homeHeroKey, height: 100.0, width: 100.0)), ), TextButton( child: const Text('PUSH'), @@ -914,7 +914,7 @@ Future main() async { // This container will appear at Y=100 Container( key: routeContainerKey, - child: Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0)), + child: const Hero(tag: 'H', child: SizedBox(key: routeHeroKey, height: 200.0, width: 200.0)), ), TextButton( child: const Text('POP'), @@ -945,7 +945,7 @@ Future main() async { const SizedBox(height: 200.0), // This container will appear at Y=200 Container( - child: Hero(tag: 'H', child: Container(key: homeHeroKey, height: 100.0, width: 100.0)), + child: const Hero(tag: 'H', child: SizedBox(key: homeHeroKey, height: 100.0, width: 100.0)), ), TextButton( child: const Text('PUSH'), @@ -1004,7 +1004,7 @@ Future main() async { // This container will appear at Y=100 Container( key: routeContainerKey, - child: Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0)), + child: const Hero(tag: 'H', child: SizedBox(key: routeHeroKey, height: 200.0, width: 200.0)), ), const SizedBox(height: 800.0), ], @@ -1024,7 +1024,7 @@ Future main() async { const SizedBox(height: 200.0), // This container will appear at Y=200 Container( - child: Hero(tag: 'H', child: Container(key: homeHeroKey, height: 100.0, width: 100.0)), + child: const Hero(tag: 'H', child: SizedBox(key: homeHeroKey, height: 100.0, width: 100.0)), ), TextButton( child: const Text('PUSH'), @@ -1080,12 +1080,12 @@ Future main() async { children: [ // This container will appear at Y=0 Container( - child: Hero( + child: const Hero( tag: 'BC', - child: Container( + child: SizedBox( key: heroBCKey, height: 150.0, - child: const Text('Hero'), + child: Text('Hero'), ), ), ), @@ -1105,12 +1105,12 @@ Future main() async { const SizedBox(height: 100.0), // This container will appear at Y=100 Container( - child: Hero( + child: const Hero( tag: 'AB', - child: Container( + child: SizedBox( key: heroABKey, height: 200.0, - child: const Text('Hero'), + child: Text('Hero'), ), ), ), @@ -1119,11 +1119,11 @@ Future main() async { onPressed: () { Navigator.push(context, routeC); }, ), Container( - child: Hero( + child: const Hero( tag: 'BC', - child: Container( + child: SizedBox( height: 150.0, - child: const Text('Hero'), + child: Text('Hero'), ), ), ), @@ -1145,12 +1145,12 @@ Future main() async { const SizedBox(height: 200.0), // This container will appear at Y=200 Container( - child: Hero( + child: const Hero( tag: 'AB', - child: Container( + child: SizedBox( height: 100.0, width: 100.0, - child: const Text('Hero'), + child: Text('Hero'), ), ), ), @@ -1309,7 +1309,7 @@ Future main() async { Hero( tag: 'a', createRectTween: createRectTween, - child: Container(height: 100.0, width: 100.0, key: firstKey), + child: SizedBox(height: 100.0, width: 100.0, key: firstKey), ), TextButton( child: const Text('two'), @@ -1332,7 +1332,7 @@ Future main() async { Hero( tag: 'a', createRectTween: createRectTween, - child: Container(height: 200.0, width: 100.0, key: secondKey), + child: SizedBox(height: 200.0, width: 100.0, key: secondKey), ), ], ), @@ -1424,7 +1424,7 @@ Future main() async { Hero( tag: 'a', createRectTween: createRectTween, - child: Container(height: 100.0, width: 100.0, key: firstKey), + child: SizedBox(height: 100.0, width: 100.0, key: firstKey), ), TextButton( child: const Text('two'), @@ -1447,7 +1447,7 @@ Future main() async { Hero( tag: 'a', createRectTween: createRectTween, - child: Container(height: 200.0, width: 100.0, key: secondKey), + child: SizedBox(height: 200.0, width: 100.0, key: secondKey), ), ], ), @@ -2402,7 +2402,7 @@ Future main() async { Hero( tag: 'hero', transitionOnUserGestures: true, - child: Container( + child: SizedBox( width: 100, child: Image( image: imageProvider, @@ -2572,7 +2572,7 @@ Future main() async { createRectTween: (Rect? begin, Rect? end) { return RectTween(begin: begin, end: end); }, - child: Container( + child: SizedBox( key: container1, height: 100, width: 100, @@ -2593,7 +2593,7 @@ Future main() async { createRectTween: (Rect? begin, Rect? end) { return RectTween(begin: begin, end: end); }, - child: Container( + child: SizedBox( key: container2, height: 200, width: 200, diff --git a/packages/flutter/test/widgets/image_resolution_test.dart b/packages/flutter/test/widgets/image_resolution_test.dart index 65baec5808..763834c216 100644 --- a/packages/flutter/test/widgets/image_resolution_test.dart +++ b/packages/flutter/test/widgets/image_resolution_test.dart @@ -137,7 +137,7 @@ Widget buildImageAtRatio(String imageName, Key key, double ratio, bool inferSize Widget buildImageCacheResized(String name, Key key, int width, int height, int cacheWidth, int cacheHeight) { return Center( child: RepaintBoundary( - child: Container( + child: SizedBox( width: 250, height: 250, child: Center( diff --git a/packages/flutter/test/widgets/image_rtl_test.dart b/packages/flutter/test/widgets/image_rtl_test.dart index 8465cf6c4d..2666bd3e5e 100644 --- a/packages/flutter/test/widgets/image_rtl_test.dart +++ b/packages/flutter/test/widgets/image_rtl_test.dart @@ -298,7 +298,7 @@ void main() { Directionality( textDirection: TextDirection.rtl, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -313,7 +313,7 @@ void main() { Duration.zero, EnginePhase.layout, // so that we don't try to paint the fake images ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) ..translate(x: 50.0, y: 0.0) ..scale(x: -1.0, y: 1.0) @@ -327,7 +327,7 @@ void main() { ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore(), ); - expect(find.byType(Container), isNot(paints..scale()..scale())); + expect(find.byType(SizedBox), isNot(paints..scale()..scale())); }); testWidgets('Image LTR with alignment topEnd (and pointless match)', (WidgetTester tester) async { @@ -335,7 +335,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -350,7 +350,7 @@ void main() { Duration.zero, EnginePhase.layout, // so that we don't try to paint the fake images ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) @@ -361,7 +361,7 @@ void main() { ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore(), ); - expect(find.byType(Container), isNot(paints..scale())); + expect(find.byType(SizedBox), isNot(paints..scale())); }); testWidgets('Image RTL with alignment topEnd', (WidgetTester tester) async { @@ -369,7 +369,7 @@ void main() { Directionality( textDirection: TextDirection.rtl, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -383,7 +383,7 @@ void main() { Duration.zero, EnginePhase.layout, // so that we don't try to paint the fake images ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0)) ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(16.0, 0.0, 32.0, 9.0)) @@ -394,7 +394,7 @@ void main() { ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(96.0, 0.0, 112.0, 9.0)) ..restore(), ); - expect(find.byType(Container), isNot(paints..scale())); + expect(find.byType(SizedBox), isNot(paints..scale())); }); testWidgets('Image LTR with alignment topEnd', (WidgetTester tester) async { @@ -402,7 +402,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -416,7 +416,7 @@ void main() { Duration.zero, EnginePhase.layout, // so that we don't try to paint the fake images ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) @@ -427,7 +427,7 @@ void main() { ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore(), ); - expect(find.byType(Container), isNot(paints..scale())); + expect(find.byType(SizedBox), isNot(paints..scale())); }); testWidgets('Image RTL with alignment center-right and match', (WidgetTester tester) async { @@ -435,7 +435,7 @@ void main() { Directionality( textDirection: TextDirection.rtl, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -447,15 +447,15 @@ void main() { ), ), ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..translate(x: 50.0, y: 0.0) ..scale(x: -1.0, y: 1.0) ..translate(x: -50.0, y: 0.0) ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(0.0, 20.5, 16.0, 29.5)) ..restore(), ); - expect(find.byType(Container), isNot(paints..scale()..scale())); - expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); + expect(find.byType(SizedBox), isNot(paints..scale()..scale())); + expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect())); }); testWidgets('Image RTL with alignment center-right and no match', (WidgetTester tester) async { @@ -463,7 +463,7 @@ void main() { Directionality( textDirection: TextDirection.rtl, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -476,11 +476,11 @@ void main() { Duration.zero, EnginePhase.layout, // so that we don't try to paint the fake images ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)), ); - expect(find.byType(Container), isNot(paints..scale())); - expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); + expect(find.byType(SizedBox), isNot(paints..scale())); + expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect())); }); testWidgets('Image LTR with alignment center-right and match', (WidgetTester tester) async { @@ -488,7 +488,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -502,11 +502,11 @@ void main() { Duration.zero, EnginePhase.layout, // so that we don't try to paint the fake images ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)), ); - expect(find.byType(Container), isNot(paints..scale())); - expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); + expect(find.byType(SizedBox), isNot(paints..scale())); + expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect())); }); testWidgets('Image LTR with alignment center-right and no match', (WidgetTester tester) async { @@ -514,7 +514,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, height: 50.0, child: Image( @@ -528,11 +528,11 @@ void main() { Duration.zero, EnginePhase.layout, // so that we don't try to paint the fake images ); - expect(find.byType(Container), paints + expect(find.byType(SizedBox), paints ..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)), ); - expect(find.byType(Container), isNot(paints..scale())); - expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); + expect(find.byType(SizedBox), isNot(paints..scale())); + expect(find.byType(SizedBox), isNot(paints..drawImageRect()..drawImageRect())); }); testWidgets('Image - Switch needing direction', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/implicit_animations_test.dart b/packages/flutter/test/widgets/implicit_animations_test.dart index 31b6cfd341..31120b29d8 100644 --- a/packages/flutter/test/widgets/implicit_animations_test.dart +++ b/packages/flutter/test/widgets/implicit_animations_test.dart @@ -547,7 +547,7 @@ class _TestTweenAnimationBuilderWidgetState extends _TestAnimatedWidgetState { duration: duration, onEnd: widget.callback, builder: (BuildContext context, double? size, Widget? child) { - return Container( + return SizedBox( child: child, width: size, height: size, diff --git a/packages/flutter/test/widgets/interactive_viewer_test.dart b/packages/flutter/test/widgets/interactive_viewer_test.dart index e2875221d6..08bc8e75f7 100644 --- a/packages/flutter/test/widgets/interactive_viewer_test.dart +++ b/packages/flutter/test/widgets/interactive_viewer_test.dart @@ -20,7 +20,7 @@ void main() { body: Center( child: InteractiveViewer( transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -31,7 +31,7 @@ void main() { // Attempting to drag to pan doesn't work because the child fits inside // the viewport and has a tight boundary. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); final Offset childInterior = Offset( childOffset.dx + 20.0, childOffset.dy + 20.0, @@ -76,7 +76,7 @@ void main() { boundaryMargin: const EdgeInsets.all(boundaryMargin), minScale: minScale, transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -86,7 +86,7 @@ void main() { expect(transformationController.value, equals(Matrix4.identity())); // Dragging to pan works only until it hits the boundary. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); final Offset childInterior = Offset( childOffset.dx + 20.0, childOffset.dy + 20.0, @@ -133,7 +133,7 @@ void main() { constrained: false, scaleEnabled: false, transformationController: transformationController, - child: Container(width: 2000.0, height: 2000.0), + child: const SizedBox(width: 2000.0, height: 2000.0), ), ), ), @@ -143,7 +143,7 @@ void main() { expect(transformationController.value, equals(Matrix4.identity())); // Attempting to move against the boundary doesn't work. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); final Offset childInterior = Offset( childOffset.dx + 20.0, childOffset.dy + 20.0, @@ -211,7 +211,7 @@ void main() { boundaryMargin: const EdgeInsets.all(double.infinity), minScale: minScale, transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -222,7 +222,7 @@ void main() { // Drag to pan works because even though the viewport fits perfectly // around the child, there is no boundary. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); final Offset childInterior = Offset( childOffset.dx + 20.0, childOffset.dy + 20.0, @@ -268,7 +268,7 @@ void main() { alignPanAxis: true, boundaryMargin: const EdgeInsets.all(double.infinity), transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -278,7 +278,7 @@ void main() { expect(transformationController.value, equals(Matrix4.identity())); // Perform a diagonal drag gesture. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); final Offset childInterior = Offset( childOffset.dx + 20.0, childOffset.dy + 20.0, @@ -308,7 +308,7 @@ void main() { alignPanAxis: true, boundaryMargin: const EdgeInsets.all(double.infinity), transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -318,7 +318,7 @@ void main() { expect(transformationController.value, equals(Matrix4.identity())); // Perform a horizontally leaning diagonal drag gesture. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); final Offset childInterior = Offset( childOffset.dx + 20.0, childOffset.dy + 10.0, @@ -350,7 +350,7 @@ void main() { boundaryMargin: const EdgeInsets.all(boundaryMargin), minScale: minScale, transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -358,7 +358,7 @@ void main() { ); // Fling the child. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); const Offset flingEnd = Offset(20.0, 15.0); await tester.flingFrom(childOffset, flingEnd, 1000.0); await tester.pump(); @@ -411,7 +411,7 @@ void main() { boundaryMargin: const EdgeInsets.all(boundaryMargin), minScale: minScale, transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -423,7 +423,7 @@ void main() { expect(translation.y, 0.0); // Pan into the corner of the boundaries. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); const Offset flingEnd = Offset(20.0, 15.0); await tester.flingFrom(childOffset, flingEnd, 1000.0); await tester.pumpAndSettle(); @@ -433,7 +433,7 @@ void main() { // Zoom out so the entire child is visible. The child will also be // translated in order to keep it inside the boundaries. - final Offset childCenter = tester.getCenter(find.byType(Container)); + final Offset childCenter = tester.getCenter(find.byType(SizedBox)); Offset scaleStart1 = Offset(childCenter.dx - 40.0, childCenter.dy); Offset scaleStart2 = Offset(childCenter.dx + 40.0, childCenter.dy); Offset scaleEnd1 = Offset(childCenter.dx - 10.0, childCenter.dy); @@ -497,7 +497,7 @@ void main() { boundaryMargin: const EdgeInsets.all(boundaryMargin), minScale: minScale, transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -510,12 +510,12 @@ void main() { // Pan into the corner of the boundaries in two gestures, since // alignPanAxis prevents diagonal panning. - final Offset childOffset1 = tester.getTopLeft(find.byType(Container)); + final Offset childOffset1 = tester.getTopLeft(find.byType(SizedBox)); const Offset flingEnd1 = Offset(20.0, 0.0); await tester.flingFrom(childOffset1, flingEnd1, 1000.0); await tester.pumpAndSettle(); await tester.pump(const Duration(seconds: 5)); - final Offset childOffset2 = tester.getTopLeft(find.byType(Container)); + final Offset childOffset2 = tester.getTopLeft(find.byType(SizedBox)); const Offset flingEnd2 = Offset(0.0, 15.0); await tester.flingFrom(childOffset2, flingEnd2, 1000.0); await tester.pumpAndSettle(); @@ -525,7 +525,7 @@ void main() { // Zoom out so the entire child is visible. The child will also be // translated in order to keep it inside the boundaries. - final Offset childCenter = tester.getCenter(find.byType(Container)); + final Offset childCenter = tester.getCenter(find.byType(SizedBox)); Offset scaleStart1 = Offset(childCenter.dx - 40.0, childCenter.dy); Offset scaleStart2 = Offset(childCenter.dx + 40.0, childCenter.dy); Offset scaleEnd1 = Offset(childCenter.dx - 10.0, childCenter.dy); @@ -584,7 +584,7 @@ void main() { body: Center( child: InteractiveViewer( transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -607,7 +607,7 @@ void main() { child: InteractiveViewer( transformationController: transformationController, scaleEnabled: false, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -645,7 +645,7 @@ void main() { onInteractionEnd: (ScaleEndDetails details){ currentVelocity = details.velocity; }, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -684,7 +684,7 @@ void main() { maxScale: 100000, minScale: 0.01, transformationController: transformationController, - child: Container(width: 1000.0, height: 1000.0), + child: const SizedBox(width: 1000.0, height: 1000.0), ), )), ), @@ -728,7 +728,7 @@ void main() { onInteractionEnd: (ScaleEndDetails details){ currentVelocity = details.velocity; }, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -818,7 +818,7 @@ void main() { child: InteractiveViewer( boundaryMargin: const EdgeInsets.all(boundaryMargin), transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -830,7 +830,7 @@ void main() { expect(translation.y, 0.0); // Start a pan gesture. - final Offset childCenter = tester.getCenter(find.byType(Container)); + final Offset childCenter = tester.getCenter(find.byType(SizedBox)); final TestGesture gesture = await tester.createGesture(); await gesture.down(childCenter); await tester.pump(); @@ -922,7 +922,7 @@ void main() { scale = details.scale; }, transformationController: transformationController, - child: Container(width: 200.0, height: 200.0), + child: const SizedBox(width: 200.0, height: 200.0), ), ), ), @@ -936,7 +936,7 @@ void main() { // Pinch to zoom isn't immediately detected for a small amount of // movement due to the GestureDetector. - final Offset childOffset = tester.getTopLeft(find.byType(Container)); + final Offset childOffset = tester.getTopLeft(find.byType(SizedBox)); final Offset childInterior = Offset( childOffset.dx + 20.0, childOffset.dy + 20.0, diff --git a/packages/flutter/test/widgets/keep_alive_test.dart b/packages/flutter/test/widgets/keep_alive_test.dart index 0d945f585f..52f8d77f31 100644 --- a/packages/flutter/test/widgets/keep_alive_test.dart +++ b/packages/flutter/test/widgets/keep_alive_test.dart @@ -103,7 +103,7 @@ void main() { addAutomaticKeepAlives: false, addRepaintBoundaries: false, addSemanticIndexes: false, - children: generateList(Container(height: 12.3, child: const Placeholder())), // about 50 widgets visible + children: generateList(const SizedBox(height: 12.3, child: Placeholder())), // about 50 widgets visible ), ), ); diff --git a/packages/flutter/test/widgets/list_view_builder_test.dart b/packages/flutter/test/widgets/list_view_builder_test.dart index ec3d95393a..1a60777fd0 100644 --- a/packages/flutter/test/widgets/list_view_builder_test.dart +++ b/packages/flutter/test/widgets/list_view_builder_test.dart @@ -22,7 +22,7 @@ void main() { itemExtent: 100.0, itemBuilder: (BuildContext context, int index) { callbackTracker.add(index); - return Container( + return SizedBox( key: ValueKey(index), height: 100.0, child: Text('$index'), @@ -70,7 +70,7 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return Container( + return SizedBox( key: ValueKey(index), width: 500.0, // this should be ignored height: 400.0, // should be overridden by itemExtent @@ -143,7 +143,7 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return Container( + return SizedBox( key: ValueKey(index), width: 400.0, // this should be overridden by itemExtent height: 500.0, // this should be ignored diff --git a/packages/flutter/test/widgets/list_view_correction_test.dart b/packages/flutter/test/widgets/list_view_correction_test.dart index 4f617d6b09..c176c63ad8 100644 --- a/packages/flutter/test/widgets/list_view_correction_test.dart +++ b/packages/flutter/test/widgets/list_view_correction_test.dart @@ -14,13 +14,13 @@ void main() { child: ListView( cacheExtent: 0.0, controller: controller, - children: [ - Container(height: 400.0, child: const Text('1')), - Container(height: 400.0, child: const Text('2')), - Container(height: 400.0, child: const Text('3')), - Container(height: 400.0, child: const Text('4')), - Container(height: 400.0, child: const Text('5')), - Container(height: 400.0, child: const Text('6')), + children: const [ + SizedBox(height: 400.0, child: Text('1')), + SizedBox(height: 400.0, child: Text('2')), + SizedBox(height: 400.0, child: Text('3')), + SizedBox(height: 400.0, child: Text('4')), + SizedBox(height: 400.0, child: Text('5')), + SizedBox(height: 400.0, child: Text('6')), ], ), ), @@ -37,13 +37,13 @@ void main() { child: ListView( cacheExtent: 0.0, controller: controller, - children: [ - Container(height: 200.0, child: const Text('1')), - Container(height: 400.0, child: const Text('2')), - Container(height: 400.0, child: const Text('3')), - Container(height: 400.0, child: const Text('4')), - Container(height: 400.0, child: const Text('5')), - Container(height: 400.0, child: const Text('6')), + children: const [ + SizedBox(height: 200.0, child: Text('1')), + SizedBox(height: 400.0, child: Text('2')), + SizedBox(height: 400.0, child: Text('3')), + SizedBox(height: 400.0, child: Text('4')), + SizedBox(height: 400.0, child: Text('5')), + SizedBox(height: 400.0, child: Text('6')), ], ), ), @@ -72,13 +72,13 @@ void main() { textDirection: TextDirection.ltr, child: ListView( controller: controller, - children: [ - Container(height: 400.0, child: const Text('1')), - Container(height: 400.0, child: const Text('2')), - Container(height: 400.0, child: const Text('3')), - Container(height: 400.0, child: const Text('4')), - Container(height: 400.0, child: const Text('5')), - Container(height: 400.0, child: const Text('6')), + children: const [ + SizedBox(height: 400.0, child: Text('1')), + SizedBox(height: 400.0, child: Text('2')), + SizedBox(height: 400.0, child: Text('3')), + SizedBox(height: 400.0, child: Text('4')), + SizedBox(height: 400.0, child: Text('5')), + SizedBox(height: 400.0, child: Text('6')), ], ), ), @@ -94,13 +94,13 @@ void main() { textDirection: TextDirection.ltr, child: ListView( controller: controller, - children: [ - Container(height: 200.0, child: const Text('1')), - Container(height: 400.0, child: const Text('2')), - Container(height: 400.0, child: const Text('3')), - Container(height: 400.0, child: const Text('4')), - Container(height: 400.0, child: const Text('5')), - Container(height: 400.0, child: const Text('6')), + children: const [ + SizedBox(height: 200.0, child: Text('1')), + SizedBox(height: 400.0, child: Text('2')), + SizedBox(height: 400.0, child: Text('3')), + SizedBox(height: 400.0, child: Text('4')), + SizedBox(height: 400.0, child: Text('5')), + SizedBox(height: 400.0, child: Text('6')), ], ), ), @@ -129,11 +129,11 @@ void main() { textDirection: TextDirection.ltr, child: ListView( controller: controller, - children: [ - Container(height: 400.0, child: const Text('0')), - Container(height: 400.0, child: const Text('1')), - Container(height: 400.0, child: const Text('2')), - Container(height: 400.0, child: const Text('3')), + children: const [ + SizedBox(height: 400.0, child: Text('0')), + SizedBox(height: 400.0, child: Text('1')), + SizedBox(height: 400.0, child: Text('2')), + SizedBox(height: 400.0, child: Text('3')), ], ), ), @@ -143,20 +143,20 @@ void main() { expect(find.text('2'), findsNothing); expect(find.text('3'), findsNothing); - final Finder findItemA = find.descendant(of: find.byType(Container), matching: find.text('A')); - final Finder findItemB = find.descendant(of: find.byType(Container), matching: find.text('B')); + final Finder findItemA = find.descendant(of: find.byType(SizedBox), matching: find.text('A')); + final Finder findItemB = find.descendant(of: find.byType(SizedBox), matching: find.text('B')); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: ListView( controller: controller, - children: [ - Container(height: 10.0, child: const Text('A')), - Container(height: 10.0, child: const Text('B')), - Container(height: 400.0, child: const Text('0')), - Container(height: 400.0, child: const Text('1')), - Container(height: 400.0, child: const Text('2')), - Container(height: 400.0, child: const Text('3')), + children: const [ + SizedBox(height: 10.0, child: Text('A')), + SizedBox(height: 10.0, child: Text('B')), + SizedBox(height: 400.0, child: Text('0')), + SizedBox(height: 400.0, child: Text('1')), + SizedBox(height: 400.0, child: Text('2')), + SizedBox(height: 400.0, child: Text('3')), ], ), ), @@ -179,13 +179,13 @@ void main() { textDirection: TextDirection.ltr, child: ListView( controller: controller, - children: [ - Container(height: 200.0, child: const Text('A')), - Container(height: 200.0, child: const Text('B')), - Container(height: 400.0, child: const Text('0')), - Container(height: 400.0, child: const Text('1')), - Container(height: 400.0, child: const Text('2')), - Container(height: 400.0, child: const Text('3')), + children: const [ + SizedBox(height: 200.0, child: Text('A')), + SizedBox(height: 200.0, child: Text('B')), + SizedBox(height: 400.0, child: Text('0')), + SizedBox(height: 400.0, child: Text('1')), + SizedBox(height: 400.0, child: Text('2')), + SizedBox(height: 400.0, child: Text('3')), ], ), ), diff --git a/packages/flutter/test/widgets/list_view_horizontal_test.dart b/packages/flutter/test/widgets/list_view_horizontal_test.dart index e1d96b5923..26b0533da0 100644 --- a/packages/flutter/test/widgets/list_view_horizontal_test.dart +++ b/packages/flutter/test/widgets/list_view_horizontal_test.dart @@ -11,7 +11,7 @@ Widget buildFrame({ bool reverse = false, required TextDirection textDirection } return Directionality( textDirection: textDirection, child: Center( - child: Container( + child: SizedBox( height: 50.0, child: ListView( itemExtent: 290.0, @@ -19,9 +19,7 @@ Widget buildFrame({ bool reverse = false, required TextDirection textDirection } reverse: reverse, physics: const BouncingScrollPhysics(), children: items.map((int item) { - return Container( - child: Text('$item'), - ); + return Text('$item'); }).toList(), ), ), diff --git a/packages/flutter/test/widgets/list_view_misc_test.dart b/packages/flutter/test/widgets/list_view_misc_test.dart index 37da9a0704..beb892edc2 100644 --- a/packages/flutter/test/widgets/list_view_misc_test.dart +++ b/packages/flutter/test/widgets/list_view_misc_test.dart @@ -14,10 +14,10 @@ void main() { textDirection: TextDirection.ltr, child: ListView( key: blockKey, - children: [ - Container( + children: const [ + SizedBox( height: 200.0, // less than 600, the height of the test area - child: const Text('Hello'), + child: Text('Hello'), ), ], ), @@ -42,10 +42,10 @@ void main() { textDirection: TextDirection.ltr, child: ListView( key: blockKey, - children: [ - Container( + children: const [ + SizedBox( height: 2000.0, // more than 600, the height of the test area - child: const Text('Hello'), + child: Text('Hello'), ), ], ), diff --git a/packages/flutter/test/widgets/list_view_test.dart b/packages/flutter/test/widgets/list_view_test.dart index c79b9482bc..5fa5bd9eca 100644 --- a/packages/flutter/test/widgets/list_view_test.dart +++ b/packages/flutter/test/widgets/list_view_test.dart @@ -402,7 +402,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, child: ListView( cacheExtent: 500.0, @@ -431,12 +431,12 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, child: ListView( cacheExtent: 500.0, - children: [ - Container( + children: const [ + SizedBox( height: 100.0, ), ], @@ -456,19 +456,19 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, child: ListView( itemExtent: 100.0, cacheExtent: 500.0, - children: [ - Container( + children: const [ + SizedBox( height: 100.0, ), - Container( + SizedBox( height: 100.0, ), - Container( + SizedBox( height: 100.0, ), ], @@ -486,13 +486,13 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, child: ListView( itemExtent: 100.0, cacheExtent: 500.0, - children: [ - Container( + children: const [ + SizedBox( height: 100.0, ), ], @@ -511,13 +511,13 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, child: ListView( scrollDirection: Axis.horizontal, itemExtent: 100.0, - children: [ - Container( + children: const [ + SizedBox( height: 100.0, ), ], @@ -547,15 +547,15 @@ void main() { return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 100.0, child: ListView( controller: controller, scrollDirection: scrollDirection, itemExtent: 50.0, - children: [ - Container( + children: const [ + SizedBox( height: 50.0, width: 50.0, ), diff --git a/packages/flutter/test/widgets/list_view_viewporting_test.dart b/packages/flutter/test/widgets/list_view_viewporting_test.dart index 6fa0c812a0..4b2f5a451d 100644 --- a/packages/flutter/test/widgets/list_view_viewporting_test.dart +++ b/packages/flutter/test/widgets/list_view_viewporting_test.dart @@ -24,7 +24,7 @@ void main() { left: ListView.builder( itemBuilder: (BuildContext context, int index) { callbackTracker.add(index); - return Container( + return SizedBox( key: ValueKey(index), height: 100.0, child: Text('$index'), @@ -70,7 +70,7 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return Container( + return SizedBox( key: ValueKey(index), width: 500.0, // this should be ignored height: 200.0, @@ -133,7 +133,7 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return Container( + return SizedBox( key: ValueKey(index), height: 500.0, // this should be ignored width: 200.0, @@ -184,7 +184,7 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return Container( + return SizedBox( key: ValueKey(index), width: 500.0, // this should be ignored height: 220.0, @@ -440,18 +440,18 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, child: ListView( cacheExtent: 500.0, controller: ScrollController(initialScrollOffset: 300.0), - children: [ - Container(height: 140.0, child: text), - Container(height: 160.0, child: text), - Container(height: 90.0, child: text), - Container(height: 110.0, child: text), - Container(height: 80.0, child: text), - Container(height: 70.0, child: text), + children: const [ + SizedBox(height: 140.0, child: text), + SizedBox(height: 160.0, child: text), + SizedBox(height: 90.0, child: text), + SizedBox(height: 110.0, child: text), + SizedBox(height: 80.0, child: text), + SizedBox(height: 70.0, child: text), ], ), ), @@ -467,7 +467,7 @@ void main() { await tester.pumpWidget( MaterialApp( home: Scaffold( - body: Container( + body: SizedBox( height: 500.0, child: CustomScrollView( controller: ScrollController(initialScrollOffset: 120.0), @@ -479,9 +479,9 @@ void main() { delegate: ListView.builder( itemExtent: 100.0, itemCount: 100, - itemBuilder: (_, __) => Container( + itemBuilder: (_, __) => const SizedBox( height: 40.0, - child: const Text('hey'), + child: Text('hey'), )).childrenDelegate), ], ), @@ -498,7 +498,7 @@ void main() { await tester.pumpWidget( Directionality( textDirection: TextDirection.rtl, - child: Container( + child: SizedBox( height: 200.0, child: ListView.builder( padding: EdgeInsets.zero, diff --git a/packages/flutter/test/widgets/list_view_with_inherited_test.dart b/packages/flutter/test/widgets/list_view_with_inherited_test.dart index 7a7ea10a8a..dae53e6c50 100644 --- a/packages/flutter/test/widgets/list_view_with_inherited_test.dart +++ b/packages/flutter/test/widgets/list_view_with_inherited_test.dart @@ -20,7 +20,7 @@ Widget buildCard(BuildContext context, int index) { return const SizedBox(height: 100); } - return Container( + return SizedBox( key: ValueKey(items[index]), height: 100.0, child: DefaultTextStyle( diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index fec534f431..6b365c0fc3 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -151,7 +151,7 @@ void main() { onSelectedItemChanged: (_) { }, childDelegate: ListWheelChildLoopingListDelegate( children: List.generate(10, (int index) { - return Container( + return SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -164,13 +164,13 @@ void main() { // The first item is at the center of the viewport. expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), const Offset(0.0, 250.0), ); // The last item is just before the first item. expect( - tester.getTopLeft(find.widgetWithText(Container, '9')), + tester.getTopLeft(find.widgetWithText(SizedBox, '9')), const Offset(0.0, 150.0), ); @@ -179,7 +179,7 @@ void main() { // We have passed the end of the list, the list should have looped back. expect( - tester.getTopLeft(find.widgetWithText(Container, '0')), + tester.getTopLeft(find.widgetWithText(SizedBox, '0')), const Offset(0.0, 250.0), ); }); @@ -197,7 +197,7 @@ void main() { onSelectedItemChanged: (_) { }, childDelegate: ListWheelChildBuilderDelegate( builder: (BuildContext context, int index) { - return Container( + return SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -212,7 +212,7 @@ void main() { controller.jumpTo(-100000.0); await tester.pump(); expect( - tester.getTopLeft(find.widgetWithText(Container, '-1000')), + tester.getTopLeft(find.widgetWithText(SizedBox, '-1000')), const Offset(0.0, 250.0), ); @@ -220,7 +220,7 @@ void main() { controller.jumpTo(100000.0); await tester.pump(); expect( - tester.getTopLeft(find.widgetWithText(Container, '1000')), + tester.getTopLeft(find.widgetWithText(SizedBox, '1000')), const Offset(0.0, 250.0), ); }); @@ -242,7 +242,7 @@ void main() { builder: (BuildContext context, int index) { if (index < -15 || index > -5) return null; - return Container( + return SizedBox( width: 400.0, height: 100.0, child: CustomPaint( @@ -362,7 +362,7 @@ void main() { expect(builtChildren.contains(index), false); builtChildren.add(index); - return Container( + return SizedBox( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -616,10 +616,10 @@ void main() { textDirection: TextDirection.ltr, child: ListWheelScrollView( itemExtent: 100.0, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -673,10 +673,10 @@ void main() { child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -703,10 +703,10 @@ void main() { controller: controller, diameterRatio: 3.0, itemExtent: 100.0, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -732,10 +732,10 @@ void main() { controller: controller, perspective: 0.0001, itemExtent: 100.0, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -761,10 +761,10 @@ void main() { child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -794,10 +794,10 @@ void main() { controller: controller, itemExtent: 100.0, offAxisFraction: 0.5, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -840,10 +840,10 @@ void main() { offAxisFraction: 0.5, useMagnifier: true, magnification: 1.5, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -888,10 +888,10 @@ void main() { child: ListWheelScrollView( itemExtent: 100.0, onSelectedItemChanged: onItemChange, - children: [ - Container( + children: const [ + SizedBox( width: 200.0, - child: const Center( + child: Center( child: Text('blah'), ), ), @@ -1275,7 +1275,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 500.0, width: 300.0, child: ListWheelScrollView( @@ -1284,7 +1284,7 @@ void main() { children: outerChildren = List.generate(10, (int i) { return Container( child: Center( - child: innerChildren[i] = Container( + child: innerChildren[i] = SizedBox( height: 50.0, width: 50.0, child: Text('Item $i'), @@ -1346,7 +1346,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 500.0, width: 300.0, child: ListWheelScrollView( @@ -1356,7 +1356,7 @@ void main() { outerChildren = List.generate(10, (int i) { return Container( child: Center( - child: innerChildren[i] = Container( + child: innerChildren[i] = SizedBox( height: 50.0, width: 50.0, child: Text('Item $i'), diff --git a/packages/flutter/test/widgets/mouse_region_test.dart b/packages/flutter/test/widgets/mouse_region_test.dart index dbaa2ae0bc..0c64d8cc44 100644 --- a/packages/flutter/test/widgets/mouse_region_test.dart +++ b/packages/flutter/test/widgets/mouse_region_test.dart @@ -575,10 +575,10 @@ void main() { }); testWidgets('applies mouse cursor', (WidgetTester tester) async { - await tester.pumpWidget(_Scaffold( + await tester.pumpWidget(const _Scaffold( topLeft: MouseRegion( cursor: SystemMouseCursors.text, - child: Container(width: 10, height: 10), + child: SizedBox(width: 10, height: 10), ), )); @@ -1085,7 +1085,7 @@ void main() { height: 100, width: 10, alignment: moved ? Alignment.topLeft : Alignment.bottomLeft, - child: Container( + child: SizedBox( height: 10, width: 10, child: HoverClient( @@ -1363,7 +1363,7 @@ void main() { addTearDown(gesture.removePointer); await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1384,7 +1384,7 @@ void main() { logs.clear(); await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1405,7 +1405,7 @@ void main() { // Compare: It repaints if the MouseRegion is deactivated. await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1430,7 +1430,7 @@ void main() { final VoidCallback onPaintChild = () { logs.add('paint'); }; await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1450,7 +1450,7 @@ void main() { logs.clear(); await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1476,7 +1476,7 @@ void main() { final VoidCallback onPaintChild = () { logPaints.add('paint'); }; await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1496,7 +1496,7 @@ void main() { logEnters.clear(); await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1526,7 +1526,7 @@ void main() { final VoidCallback onPaintChild = () { logPaints.add('paint'); }; await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1548,7 +1548,7 @@ void main() { logEnters.clear(); await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( @@ -1569,7 +1569,7 @@ void main() { logEnters.clear(); await tester.pumpWidget(_Scaffold( - topLeft: Container( + topLeft: SizedBox( height: 10, width: 10, child: MouseRegion( diff --git a/packages/flutter/test/widgets/nested_scroll_view_test.dart b/packages/flutter/test/widgets/nested_scroll_view_test.dart index 3bbdf86b1d..e472c21f8a 100644 --- a/packages/flutter/test/widgets/nested_scroll_view_test.dart +++ b/packages/flutter/test/widgets/nested_scroll_view_test.dart @@ -71,43 +71,41 @@ Widget buildTest({ body: TabBarView( children: [ ListView( - children: [ - Container( + children: const [ + SizedBox( height: 300.0, - child: const Text('aaa1'), + child: Text('aaa1'), ), - Container( + SizedBox( height: 200.0, - child: const Text('aaa2'), + child: Text('aaa2'), ), - Container( + SizedBox( height: 100.0, - child: const Text('aaa3'), + child: Text('aaa3'), ), - Container( + SizedBox( height: 50.0, - child: const Text('aaa4'), + child: Text('aaa4'), ), ], ), ListView( dragStartBehavior: DragStartBehavior.down, - children: [ - Container( + children: const [ + SizedBox( height: 100.0, - child: const Text('bbb1'), + child: Text('bbb1'), ), ], ), - Container( - child: const Center(child: Text('ccc1')), - ), + const Center(child: Text('ccc1')), ListView( dragStartBehavior: DragStartBehavior.down, - children: [ - Container( + children: const [ + SizedBox( height: 10000.0, - child: const Text('ddd1'), + child: Text('ddd1'), ), ], ), @@ -773,11 +771,11 @@ void main() { ), ]; }, - body: SingleChildScrollView( + body: const SingleChildScrollView( dragStartBehavior: DragStartBehavior.down, - child: Container( + child: SizedBox( height: 1000.0, - child: const Placeholder(key: key2), + child: Placeholder(key: key2), ), ), ), @@ -2391,9 +2389,9 @@ class _TestLayoutExtentIsNegative extends StatelessWidget { pinned: true, forceElevated: innerBoxIsScrolled, backgroundColor: Colors.blue[300], - title: Container( + title: const SizedBox( height: 50, - child: const Center( + child: Center( child: Text('Sticky Header'), ), ), diff --git a/packages/flutter/test/widgets/overflow_box_test.dart b/packages/flutter/test/widgets/overflow_box_test.dart index 182e99534d..f4fef409db 100644 --- a/packages/flutter/test/widgets/overflow_box_test.dart +++ b/packages/flutter/test/widgets/overflow_box_test.dart @@ -58,7 +58,7 @@ void main() { child: SizedOverflowBox( size: const Size(100.0, 100.0), alignment: Alignment.topRight, - child: Container(height: 50.0, width: 50.0, key: inner), + child: SizedBox(height: 50.0, width: 50.0, key: inner), ), ), )); @@ -81,7 +81,7 @@ void main() { child: SizedOverflowBox( size: const Size(100.0, 100.0), alignment: AlignmentDirectional.bottomStart, - child: Container(height: 50.0, width: 50.0, key: inner), + child: SizedBox(height: 50.0, width: 50.0, key: inner), ), ), )); diff --git a/packages/flutter/test/widgets/overscroll_indicator_test.dart b/packages/flutter/test/widgets/overscroll_indicator_test.dart index 2f2121b7c6..1add90f3ff 100644 --- a/packages/flutter/test/widgets/overscroll_indicator_test.dart +++ b/packages/flutter/test/widgets/overscroll_indicator_test.dart @@ -65,11 +65,11 @@ void main() { axisDirection: AxisDirection.down, color: const Color(0x0DFFFFFF), notificationPredicate: (ScrollNotification notification) => notification.depth == 1, - child: SingleChildScrollView( + child: const SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Container( + child: SizedBox( width: 600.0, - child: const CustomScrollView( + child: CustomScrollView( slivers: [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], diff --git a/packages/flutter/test/widgets/pageable_list_test.dart b/packages/flutter/test/widgets/pageable_list_test.dart index 2d42271bf9..471d3f5151 100644 --- a/packages/flutter/test/widgets/pageable_list_test.dart +++ b/packages/flutter/test/widgets/pageable_list_test.dart @@ -11,7 +11,7 @@ final List globalKeys = defaultPages.map((_) => GlobalKey( int? currentPage; Widget buildPage(int page) { - return Container( + return SizedBox( key: globalKeys[page], width: pageSize.width, height: pageSize.height, @@ -36,7 +36,7 @@ Widget buildFrame({ return Directionality( textDirection: textDirection, child: Center( - child: Container( + child: SizedBox( width: pageSize.width, height: pageSize.height, child: child, ), ), diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index 99629ea9ac..30fc72cf1b 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -141,11 +141,11 @@ void main() { // │ // ──────────────────────────── testWidgets('entirely overlapping, direct child', (WidgetTester tester) async { - final List children = [ - Container( + const List children = [ + SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 1.0, color: Colors.green, child: Material( @@ -169,19 +169,19 @@ void main() { // │ │ // ──────────────────────────── testWidgets('entirely overlapping, correct painting order', (WidgetTester tester) async { - final List children = [ - Container( + const List children = [ + SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 1.0, color: Colors.green, ), ), - Container( + SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.blue, ), @@ -201,19 +201,19 @@ void main() { // │ │ // ──────────────────────────── testWidgets('entirely overlapping, wrong painting order', (WidgetTester tester) async { - final List children = [ - Container( + const List children = [ + SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.green, ), ), - Container( + SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 1.0, color: Colors.blue, ), @@ -237,10 +237,10 @@ void main() { final List children = [ Positioned.fromRect( rect: const Rect.fromLTWH(150, 150, 150, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 3.0, color: Colors.brown, ), @@ -248,10 +248,10 @@ void main() { ), Positioned.fromRect( rect: const Rect.fromLTWH(20, 20, 140, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.red, shape: CircleBorder(), @@ -275,10 +275,10 @@ void main() { final List children = [ Positioned.fromRect( rect: const Rect.fromLTWH(20, 20, 140, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 3.0, color: Colors.brown, ), @@ -286,10 +286,10 @@ void main() { ), Positioned.fromRect( rect: const Rect.fromLTWH(50, 50, 100, 100), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.red, shape: CircleBorder(), @@ -313,10 +313,10 @@ void main() { final List children = [ Positioned.fromRect( rect: const Rect.fromLTWH(150, 150, 150, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 3.0, color: Colors.brown, ), @@ -324,10 +324,10 @@ void main() { ), Positioned.fromRect( rect: const Rect.fromLTWH(30, 20, 150, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.red, shape: CircleBorder(), @@ -354,10 +354,10 @@ void main() { final List children = [ Positioned.fromRect( rect: const Rect.fromLTWH(150, 150, 150, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 1.0, color: Colors.brown, child: Padding( @@ -372,10 +372,10 @@ void main() { ), Positioned.fromRect( rect: const Rect.fromLTWH(30, 20, 180, 180), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 1.0, color: Colors.red, ), @@ -398,10 +398,10 @@ void main() { final List children = [ Positioned.fromRect( rect: const Rect.fromLTWH(150, 150, 150, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 3.0, color: Colors.brown, ), @@ -409,10 +409,10 @@ void main() { ), Positioned.fromRect( rect: const Rect.fromLTWH(30, 20, 150, 150), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.red, shape: CircleBorder(), @@ -442,7 +442,7 @@ void main() { final List children = [ Positioned.fromRect( rect: const Rect.fromLTWH(140, 100, 140, 150), - child: Container( + child: SizedBox( width: 300, height: 300, child: Transform.rotate( @@ -456,10 +456,10 @@ void main() { ), Positioned.fromRect( rect: const Rect.fromLTWH(50, 50, 100, 100), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.red, shape: CircleBorder()), @@ -483,7 +483,7 @@ void main() { final List children = [ Positioned.fromRect( rect: const Rect.fromLTWH(140, 100, 140, 150), - child: Container( + child: SizedBox( width: 300, height: 300, child: Transform.rotate( @@ -497,10 +497,10 @@ void main() { ), Positioned.fromRect( rect: const Rect.fromLTWH(50, 50, 100, 100), - child: Container( + child: const SizedBox( width: 300, height: 300, - child: const Material( + child: Material( elevation: 2.0, color: Colors.red, shape: CircleBorder()), diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index 4d38a5813e..cb6fbe7eae 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -1885,16 +1885,16 @@ void main() { viewsController.registerViewType('webview'); await tester.pumpWidget( - Container(width: 300, height: 600, + SizedBox(width: 300, height: 600, child: Stack( alignment: Alignment.topLeft, children: [ Transform.translate( offset: const Offset(0, 100), - child: Container( + child: const SizedBox( width: 300, height: 500, - child: const UiKitView(viewType: 'webview', layoutDirection: TextDirection.ltr)),), + child: UiKitView(viewType: 'webview', layoutDirection: TextDirection.ltr)),), Transform.translate( offset: const Offset(0, 500), child: Container( diff --git a/packages/flutter/test/widgets/positioned_test.dart b/packages/flutter/test/widgets/positioned_test.dart index 69ce82256c..d84a2d3e96 100644 --- a/packages/flutter/test/widgets/positioned_test.dart +++ b/packages/flutter/test/widgets/positioned_test.dart @@ -86,7 +86,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 100.0, width: 100.0, child: Stack( diff --git a/packages/flutter/test/widgets/reorderable_list_test.dart b/packages/flutter/test/widgets/reorderable_list_test.dart index aa7ec82621..237b78d704 100644 --- a/packages/flutter/test/widgets/reorderable_list_test.dart +++ b/packages/flutter/test/widgets/reorderable_list_test.dart @@ -25,7 +25,7 @@ void main() { }); }, itemBuilder: (BuildContext context, int index) { - return Container( + return SizedBox( height: 100, child: Text('item ${items[index]}'), ); @@ -63,7 +63,7 @@ void main() { }); }, itemBuilder: (BuildContext context, int index) { - return Container( + return SizedBox( height: 100, child: Text('item ${items[index]}'), ); diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 77ed85d41b..3d29162e61 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -205,7 +205,7 @@ void main() { child: ListView( itemExtent: 100.0, children: [ - Container( + SizedBox( key: const Key('container'), height: 100.0, child: StateMarker(key: key), @@ -279,7 +279,7 @@ void main() { await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - Container(width: 100.0, height: 100.0, child: StateMarker(key: key)), + SizedBox(width: 100.0, height: 100.0, child: StateMarker(key: key)), const SizedBox(width: 100.0, height: 100.0), ], )); @@ -303,7 +303,7 @@ void main() { textDirection: TextDirection.ltr, children: [ const SizedBox(width: 100.0, height: 100.0), - Container(width: 100.0, height: 100.0, child: StateMarker(key: key)), + SizedBox(width: 100.0, height: 100.0, child: StateMarker(key: key)), ], )); diff --git a/packages/flutter/test/widgets/row_test.dart b/packages/flutter/test/widgets/row_test.dart index 4671ace3e7..b1e44787ab 100644 --- a/packages/flutter/test/widgets/row_test.dart +++ b/packages/flutter/test/widgets/row_test.dart @@ -46,9 +46,9 @@ void main() { child: Row( key: rowKey, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Expanded(child: SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2))), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -77,9 +77,9 @@ void main() { child: Row( key: rowKey, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -108,8 +108,8 @@ void main() { key: rowKey, mainAxisAlignment: MainAxisAlignment.center, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), ], ), )); @@ -139,9 +139,9 @@ void main() { key: rowKey, mainAxisAlignment: MainAxisAlignment.end, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -171,9 +171,9 @@ void main() { key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -204,10 +204,10 @@ void main() { key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), - Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child3Key, width: 100.0, height: 100.0, child: log(4)), ], ), )); @@ -237,9 +237,9 @@ void main() { key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 200.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 200.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 200.0, height: 100.0, child: log(3)), ], ), )); @@ -268,8 +268,8 @@ void main() { key: rowKey, mainAxisSize: MainAxisSize.min, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 150.0, height: 100.0, child: log(2)), ], ), )); @@ -285,14 +285,14 @@ void main() { const Key childKey = Key('childKey'); await tester.pumpWidget(Center( - child: Container( + child: SizedBox( width: 0.0, height: 0.0, child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( + children: const [ + SizedBox( key: childKey, width: 100.0, height: 100.0, @@ -325,9 +325,9 @@ void main() { key: rowKey, textDirection: TextDirection.ltr, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Expanded(child: SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2))), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -375,9 +375,9 @@ void main() { key: rowKey, textDirection: TextDirection.ltr, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -424,8 +424,8 @@ void main() { mainAxisAlignment: MainAxisAlignment.center, textDirection: TextDirection.ltr, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), ], ), )); @@ -467,9 +467,9 @@ void main() { textDirection: TextDirection.ltr, mainAxisAlignment: MainAxisAlignment.end, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -517,9 +517,9 @@ void main() { mainAxisAlignment: MainAxisAlignment.spaceBetween, textDirection: TextDirection.ltr, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -568,10 +568,10 @@ void main() { mainAxisAlignment: MainAxisAlignment.spaceAround, textDirection: TextDirection.ltr, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), - Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child3Key, width: 100.0, height: 100.0, child: log(4)), ], ), )); @@ -625,9 +625,9 @@ void main() { mainAxisAlignment: MainAxisAlignment.spaceEvenly, textDirection: TextDirection.ltr, children: [ - Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 200.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 200.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 200.0, height: 100.0, child: log(3)), ], ), )); @@ -674,8 +674,8 @@ void main() { mainAxisSize: MainAxisSize.min, textDirection: TextDirection.ltr, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 150.0, height: 100.0, child: log(2)), ], ), )); @@ -707,15 +707,15 @@ void main() { const Key childKey = Key('childKey'); await tester.pumpWidget(Center( - child: Container( + child: SizedBox( width: 0.0, height: 0.0, child: Row( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( + children: const [ + SizedBox( key: childKey, width: 100.0, height: 100.0, @@ -748,9 +748,9 @@ void main() { key: rowKey, textDirection: TextDirection.rtl, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Expanded(child: SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2))), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -798,9 +798,9 @@ void main() { key: rowKey, textDirection: TextDirection.rtl, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -847,8 +847,8 @@ void main() { mainAxisAlignment: MainAxisAlignment.center, textDirection: TextDirection.rtl, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), ], ), )); @@ -890,9 +890,9 @@ void main() { textDirection: TextDirection.rtl, mainAxisAlignment: MainAxisAlignment.end, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -940,9 +940,9 @@ void main() { mainAxisAlignment: MainAxisAlignment.spaceBetween, textDirection: TextDirection.rtl, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -991,10 +991,10 @@ void main() { mainAxisAlignment: MainAxisAlignment.spaceAround, textDirection: TextDirection.rtl, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), - Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + SizedBox(key: child3Key, width: 100.0, height: 100.0, child: log(4)), ], ), )); @@ -1048,9 +1048,9 @@ void main() { mainAxisAlignment: MainAxisAlignment.spaceEvenly, textDirection: TextDirection.rtl, children: [ - Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), - Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), + SizedBox(key: child0Key, width: 200.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 200.0, height: 100.0, child: log(2)), + SizedBox(key: child2Key, width: 200.0, height: 100.0, child: log(3)), ], ), )); @@ -1097,8 +1097,8 @@ void main() { mainAxisSize: MainAxisSize.min, textDirection: TextDirection.rtl, children: [ - Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), + SizedBox(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + SizedBox(key: child1Key, width: 150.0, height: 100.0, child: log(2)), ], ), )); @@ -1130,15 +1130,15 @@ void main() { const Key childKey = Key('childKey'); await tester.pumpWidget(Center( - child: Container( + child: SizedBox( width: 0.0, height: 0.0, child: Row( textDirection: TextDirection.rtl, mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( + children: const [ + SizedBox( key: childKey, width: 100.0, height: 100.0, diff --git a/packages/flutter/test/widgets/scroll_activity_test.dart b/packages/flutter/test/widgets/scroll_activity_test.dart index 986408acb0..7ab745556c 100644 --- a/packages/flutter/test/widgets/scroll_activity_test.dart +++ b/packages/flutter/test/widgets/scroll_activity_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; List children(int n) { return List.generate(n, (int i) { - return Container(height: 100.0, child: Text('$i')); + return SizedBox(height: 100.0, child: Text('$i')); }); } diff --git a/packages/flutter/test/widgets/scroll_controller_test.dart b/packages/flutter/test/widgets/scroll_controller_test.dart index 688826b4c3..a2a94f0eb8 100644 --- a/packages/flutter/test/widgets/scroll_controller_test.dart +++ b/packages/flutter/test/widgets/scroll_controller_test.dart @@ -17,7 +17,7 @@ void main() { child: ListView( controller: controller, children: kStates.map((String state) { - return Container( + return SizedBox( height: 200.0, child: Text(state), ); @@ -56,7 +56,7 @@ void main() { key: const Key('second'), controller: controller, children: kStates.map((String state) { - return Container( + return SizedBox( height: 200.0, child: Text(state), ); @@ -82,7 +82,7 @@ void main() { key: const Key('second'), controller: controller2, children: kStates.map((String state) { - return Container( + return SizedBox( height: 200.0, child: Text(state), ); @@ -106,7 +106,7 @@ void main() { controller: controller2, physics: const BouncingScrollPhysics(), children: kStates.map((String state) { - return Container( + return SizedBox( height: 200.0, child: Text(state), ); @@ -213,7 +213,7 @@ void main() { child: ListView( controller: controller, children: kStates.map((String state) { - return Container(height: 200.0, child: Text(state)); + return SizedBox(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -222,7 +222,7 @@ void main() { child: ListView( controller: controller, children: kStates.map((String state) { - return Container(height: 200.0, child: Text(state)); + return SizedBox(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -253,7 +253,7 @@ void main() { child: ListView( controller: controller, children: kStates.map((String state) { - return Container(height: 200.0, child: Text(state)); + return SizedBox(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -262,7 +262,7 @@ void main() { child: ListView( controller: controller, children: kStates.map((String state) { - return Container(height: 200.0, child: Text(state)); + return SizedBox(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -291,7 +291,7 @@ void main() { child: ListView( controller: controller, children: kStates.map((String state) { - return Container(height: 200.0, child: Text(state)); + return SizedBox(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -324,7 +324,7 @@ void main() { key: UniqueKey(), // it's a different ListView every time controller: controller, children: List.generate(50, (int index) { - return Container(height: 100.0, child: Text('Item $index')); + return SizedBox(height: 100.0, child: Text('Item $index')); }).toList(), ), ), @@ -339,18 +339,18 @@ void main() { // scroll offset. ScrollController controller = ScrollController(initialScrollOffset: 200.0); await tester.pumpWidget(buildFrame(controller)); - expect(tester.getTopLeft(find.widgetWithText(Container, 'Item 2')), Offset.zero); + expect(tester.getTopLeft(find.widgetWithText(SizedBox, 'Item 2')), Offset.zero); controller.jumpTo(2000.0); await tester.pump(); - expect(tester.getTopLeft(find.widgetWithText(Container, 'Item 20')), Offset.zero); + expect(tester.getTopLeft(find.widgetWithText(SizedBox, 'Item 20')), Offset.zero); // The initialScrollOffset isn't used in this case, because the scrolloffset // can be restored. controller = ScrollController(initialScrollOffset: 25.0); await tester.pumpWidget(buildFrame(controller)); expect(controller.offset, 2000.0); - expect(tester.getTopLeft(find.widgetWithText(Container, 'Item 20')), Offset.zero); + expect(tester.getTopLeft(find.widgetWithText(SizedBox, 'Item 20')), Offset.zero); // keepScrollOffset: false. The scroll offset is -not- restored // when the ListView is recreated with a new ScrollController and @@ -359,7 +359,7 @@ void main() { controller = ScrollController(keepScrollOffset: false, initialScrollOffset: 100.0); await tester.pumpWidget(buildFrame(controller)); expect(controller.offset, 100.0); - expect(tester.getTopLeft(find.widgetWithText(Container, 'Item 1')), Offset.zero); + expect(tester.getTopLeft(find.widgetWithText(SizedBox, 'Item 1')), Offset.zero); }); } diff --git a/packages/flutter/test/widgets/scroll_view_test.dart b/packages/flutter/test/widgets/scroll_view_test.dart index 49d636147e..b7eebb7aa9 100644 --- a/packages/flutter/test/widgets/scroll_view_test.dart +++ b/packages/flutter/test/widgets/scroll_view_test.dart @@ -851,7 +851,7 @@ void main() { child: ListView( controller: controller, children: kStates.map((String state) { - return Container( + return SizedBox( height: 200.0, child: Text(state), ); diff --git a/packages/flutter/test/widgets/scrollable_dispose_test.dart b/packages/flutter/test/widgets/scrollable_dispose_test.dart index 657b79807e..79eaf6bc86 100644 --- a/packages/flutter/test/widgets/scrollable_dispose_test.dart +++ b/packages/flutter/test/widgets/scrollable_dispose_test.dart @@ -41,7 +41,7 @@ void main() { width: 400.0, child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: Container( + child: SizedBox( width: 500.0, child: ListView.builder( controller: controller, diff --git a/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart b/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart index bb504d7cb6..cdd2c5bcf2 100644 --- a/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart +++ b/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart @@ -15,19 +15,17 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 50.0, child: ListView( dragStartBehavior: DragStartBehavior.down, itemExtent: 290.0, scrollDirection: Axis.horizontal, children: items.map((int item) { - return Container( - child: GestureDetector( - onTap: () { tapped.add(item); }, - child: Text('$item'), - dragStartBehavior: DragStartBehavior.down, - ), + return GestureDetector( + onTap: () { tapped.add(item); }, + child: Text('$item'), + dragStartBehavior: DragStartBehavior.down, ); }).toList(), ), @@ -59,7 +57,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 50.0, child: ListView( dragStartBehavior: DragStartBehavior.down, diff --git a/packages/flutter/test/widgets/scrollable_restoration_test.dart b/packages/flutter/test/widgets/scrollable_restoration_test.dart index db666fffbe..984f680a96 100644 --- a/packages/flutter/test/widgets/scrollable_restoration_test.dart +++ b/packages/flutter/test/widgets/scrollable_restoration_test.dart @@ -18,7 +18,7 @@ void main() { delegate: SliverChildListDelegate( List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -41,7 +41,7 @@ void main() { cacheExtent: 0, children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -59,7 +59,7 @@ void main() { child: ListView.builder( restorationId: 'list', cacheExtent: 0, - itemBuilder: (BuildContext context, int index) => Container( + itemBuilder: (BuildContext context, int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -78,7 +78,7 @@ void main() { cacheExtent: 0, itemCount: 50, separatorBuilder: (BuildContext context, int index) => const SizedBox.shrink(), - itemBuilder: (BuildContext context, int index) => Container( + itemBuilder: (BuildContext context, int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -98,7 +98,7 @@ void main() { childrenDelegate: SliverChildListDelegate( List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -120,7 +120,7 @@ void main() { gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 1), children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -139,7 +139,7 @@ void main() { restorationId: 'grid', cacheExtent: 0, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 1), - itemBuilder: (BuildContext context, int index) => Container( + itemBuilder: (BuildContext context, int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -160,7 +160,7 @@ void main() { childrenDelegate: SliverChildListDelegate( List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -182,7 +182,7 @@ void main() { crossAxisCount: 1, children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -203,7 +203,7 @@ void main() { maxCrossAxisExtent: 50, children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -223,7 +223,7 @@ void main() { child: Column( children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -285,7 +285,7 @@ void main() { TestHarness( child: PageView.builder( restorationId: 'pager', - itemBuilder: (BuildContext context, int index) => Container( + itemBuilder: (BuildContext context, int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -304,7 +304,7 @@ void main() { childrenDelegate: SliverChildListDelegate( List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -345,7 +345,7 @@ void main() { childDelegate: ListWheelChildListDelegate( children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -383,7 +383,7 @@ void main() { cacheExtent: 0, children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), @@ -434,7 +434,7 @@ void main() { cacheExtent: 0, children: List.generate( 50, - (int index) => Container( + (int index) => SizedBox( height: 50, child: Text('Tile $index'), ), diff --git a/packages/flutter/test/widgets/scrollable_semantics_test.dart b/packages/flutter/test/widgets/scrollable_semantics_test.dart index 1369810fb7..0c393a38d4 100644 --- a/packages/flutter/test/widgets/scrollable_semantics_test.dart +++ b/packages/flutter/test/widgets/scrollable_semantics_test.dart @@ -50,7 +50,7 @@ void main() { const double kItemHeight = 40.0; final List containers = List.generate(80, (int i) => MergeSemantics( - child: Container( + child: SizedBox( height: kItemHeight, child: Text('container $i', textDirection: TextDirection.ltr), ), @@ -89,7 +89,7 @@ void main() { const double kExpandedAppBarHeight = 56.0; final List containers = List.generate(80, (int i) => MergeSemantics( - child: Container( + child: SizedBox( height: kItemHeight, child: Text('container $i'), ), @@ -153,7 +153,7 @@ void main() { final List children = []; final List slivers = List.generate(30, (int i) { final Widget child = MergeSemantics( - child: Container( + child: SizedBox( child: Text('Item $i'), height: 72.0, ), @@ -307,7 +307,7 @@ void main() { testWidgets('Semantics tree is populated mid-scroll', (WidgetTester tester) async { semantics = SemanticsTester(tester); - final List children = List.generate(80, (int i) => Container( + final List children = List.generate(80, (int i) => SizedBox( child: Text('Item $i'), height: 40.0, )); @@ -335,7 +335,7 @@ void main() { textDirection: TextDirection.ltr, child: ListView( children: List.generate(40, (int i) { - return Container( + return SizedBox( child: Text('item $i'), height: 400.0, ); @@ -409,7 +409,7 @@ void main() { setUp(() { children = List.generate(10, (int i) { return MergeSemantics( - child: Container( + child: SizedBox( height: kItemHeight, child: Text('container $i'), ), @@ -423,7 +423,7 @@ void main() { widgetUnderTest = Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 2 * kItemHeight, child: ListView( controller: scrollController, @@ -499,7 +499,7 @@ void main() { key: i == 5 ? center : null, child: MergeSemantics( key: ValueKey(i), - child: Container( + child: SizedBox( height: kItemHeight, child: Text('container $i'), ), @@ -521,7 +521,7 @@ void main() { widgetUnderTest = Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 2 * kItemHeight, child: Scrollable( controller: scrollController, diff --git a/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart b/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart index f94f0a62b9..689e8ed3bc 100644 --- a/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart +++ b/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart @@ -15,7 +15,7 @@ void main() { final SemanticsTester semantics = SemanticsTester(tester); final List listChildren = List.generate(30, (int i) { - return Container( + return SizedBox( height: 200.0, child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -189,7 +189,7 @@ void main() { final SemanticsTester semantics = SemanticsTester(tester); final List listChildren = List.generate(30, (int i) { - return Container( + return SizedBox( height: 200.0, child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -329,7 +329,7 @@ void main() { final SemanticsTester semantics = SemanticsTester(tester); final List listChildren = List.generate(30, (int i) { - return Container( + return SizedBox( height: 200.0, child: Text('Item $i'), ); @@ -459,7 +459,7 @@ void main() { final List listChildren = List.generate(30, (int i) { return SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 200.0, child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -595,7 +595,7 @@ void main() { final SemanticsTester semantics = SemanticsTester(tester); final List listChildren = List.generate(30, (int i) { - return Container( + return SizedBox( height: 200.0, child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -742,7 +742,7 @@ void main() { final int item = i - 15; return SliverToBoxAdapter( key: ValueKey(item), - child: Container( + child: SizedBox( height: 200.0, child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/packages/flutter/test/widgets/scrollable_test.dart b/packages/flutter/test/widgets/scrollable_test.dart index 316f672f41..42168a37dd 100644 --- a/packages/flutter/test/widgets/scrollable_test.dart +++ b/packages/flutter/test/widgets/scrollable_test.dart @@ -45,19 +45,19 @@ Future pumpDoubleScrollableTest( theme: ThemeData( platform: platform, ), - home: CustomScrollView( + home: const CustomScrollView( slivers: [ SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 300, - child: const CustomScrollView( + child: CustomScrollView( slivers: [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], ), ), ), - const SliverToBoxAdapter(child: SizedBox(height: 2000.0)), + SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], ), )); @@ -1168,7 +1168,7 @@ void main() { Text('SingleChildScrollView $i'), ] ), - Container( + SizedBox( height: 3000, width: 400, child: ListView.builder( diff --git a/packages/flutter/test/widgets/selectable_text_test.dart b/packages/flutter/test/widgets/selectable_text_test.dart index 3f7ceb264d..6ef1da32dd 100644 --- a/packages/flutter/test/widgets/selectable_text_test.dart +++ b/packages/flutter/test/widgets/selectable_text_test.dart @@ -495,13 +495,13 @@ void main() { testWidgets('selectable text selection toolbar renders correctly inside opacity', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Scaffold( body: Center( - child: Container( + child: SizedBox( width: 100, height: 100, - child: const Opacity( + child: Opacity( opacity: 0.5, child: SelectableText('selectable text'), ), @@ -1306,7 +1306,7 @@ void main() { try { await tester.pumpWidget( overlay( - child: Container( + child: SizedBox( width: 300.0, child: SelectableText( 'abcd', @@ -1340,9 +1340,9 @@ void main() { testWidgets('Can align to center', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const SelectableText( + child: SelectableText( 'abcd', textAlign: TextAlign.center, ), @@ -1362,9 +1362,9 @@ void main() { testWidgets('Can align to center within center', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const Center( + child: Center( child: SelectableText( 'abcd', textAlign: TextAlign.center, @@ -3906,9 +3906,9 @@ void main() { testWidgets('Caret center position', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const SelectableText( + child: SelectableText( 'abcd', textAlign: TextAlign.center, ), @@ -3942,9 +3942,9 @@ void main() { testWidgets('Caret indexes into trailing whitespace center align', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: Container( + child: const SizedBox( width: 300.0, - child: const SelectableText( + child: SelectableText( 'abcd ', textAlign: TextAlign.center, ), diff --git a/packages/flutter/test/widgets/semantics_1_test.dart b/packages/flutter/test/widgets/semantics_1_test.dart index 599b02b462..a3acb1f938 100644 --- a/packages/flutter/test/widgets/semantics_1_test.dart +++ b/packages/flutter/test/widgets/semantics_1_test.dart @@ -45,7 +45,7 @@ void main() { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( + SizedBox( height: 10.0, child: Semantics( label: 'child1', @@ -53,7 +53,7 @@ void main() { selected: true, ), ), - Container( + SizedBox( height: 10.0, child: IgnorePointer( ignoring: true, @@ -87,7 +87,7 @@ void main() { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( + SizedBox( height: 10.0, child: Semantics( label: 'child1', @@ -95,7 +95,7 @@ void main() { selected: true, ), ), - Container( + SizedBox( height: 10.0, child: IgnorePointer( ignoring: false, @@ -141,7 +141,7 @@ void main() { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( + SizedBox( height: 10.0, child: Semantics( label: 'child1', @@ -149,7 +149,7 @@ void main() { selected: true, ), ), - Container( + SizedBox( height: 10.0, child: IgnorePointer( ignoring: true, @@ -183,7 +183,7 @@ void main() { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( + SizedBox( height: 10.0, child: Semantics( label: 'child1', @@ -191,7 +191,7 @@ void main() { selected: true, ), ), - Container( + SizedBox( height: 10.0, child: IgnorePointer( ignoring: false, diff --git a/packages/flutter/test/widgets/semantics_2_test.dart b/packages/flutter/test/widgets/semantics_2_test.dart index b9760098db..21988a6667 100644 --- a/packages/flutter/test/widgets/semantics_2_test.dart +++ b/packages/flutter/test/widgets/semantics_2_test.dart @@ -23,7 +23,7 @@ void main() { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( + SizedBox( height: 10.0, child: Semantics( label: 'child1', @@ -31,7 +31,7 @@ void main() { selected: true, ), ), - Container( + SizedBox( height: 10.0, child: IgnorePointer( ignoring: false, @@ -77,7 +77,7 @@ void main() { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( + SizedBox( height: 10.0, child: Semantics( label: 'child1', @@ -85,7 +85,7 @@ void main() { selected: true, ), ), - Container( + SizedBox( height: 10.0, child: IgnorePointer( ignoring: true, @@ -119,7 +119,7 @@ void main() { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Container( + SizedBox( height: 10.0, child: Semantics( label: 'child1', @@ -127,7 +127,7 @@ void main() { selected: true, ), ), - Container( + SizedBox( height: 10.0, child: IgnorePointer( ignoring: false, diff --git a/packages/flutter/test/widgets/semantics_clipping_test.dart b/packages/flutter/test/widgets/semantics_clipping_test.dart index b4174a937f..4384afc95b 100644 --- a/packages/flutter/test/widgets/semantics_clipping_test.dart +++ b/packages/flutter/test/widgets/semantics_clipping_test.dart @@ -15,22 +15,22 @@ void main() { await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, child: Flex( direction: Axis.horizontal, - children: [ - Container( + children: const [ + SizedBox( width: 75.0, - child: const Text('1'), + child: Text('1'), ), - Container( + SizedBox( width: 75.0, - child: const Text('2'), + child: Text('2'), ), - Container( + SizedBox( width: 75.0, - child: const Text('3'), + child: Text('3'), ), ], ), @@ -70,26 +70,26 @@ void main() { await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 100.0, child: Flex( direction: Axis.horizontal, children: [ - Container( + const SizedBox( width: 75.0, - child: const Text('1'), + child: Text('1'), ), MergeSemantics( child: Flex( direction: Axis.horizontal, - children: [ - Container( + children: const [ + SizedBox( width: 75.0, - child: const Text('2'), + child: Text('2'), ), - Container( + SizedBox( width: 75.0, - child: const Text('3'), + child: Text('3'), ), ], ), diff --git a/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart b/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart index 76855469ed..1fb36cd5ec 100644 --- a/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart +++ b/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart @@ -92,7 +92,7 @@ Widget _buildTestWidget({ Expanded( child: Container(), ), - Container( + SizedBox( height: 500.0, child: ListView( controller: controller, diff --git a/packages/flutter/test/widgets/shortcuts_test.dart b/packages/flutter/test/widgets/shortcuts_test.dart index 0098a9f8e1..fbd7a32d75 100644 --- a/packages/flutter/test/widgets/shortcuts_test.dart +++ b/packages/flutter/test/widgets/shortcuts_test.dart @@ -221,7 +221,7 @@ void main() { }, child: Focus( autofocus: true, - child: Container(key: containerKey, width: 100, height: 100), + child: SizedBox(key: containerKey, width: 100, height: 100), ), ), ); @@ -282,7 +282,7 @@ void main() { }, child: Focus( autofocus: true, - child: Container(key: containerKey, width: 100, height: 100), + child: SizedBox(key: containerKey, width: 100, height: 100), ), ), ), @@ -319,7 +319,7 @@ void main() { }, child: Focus( autofocus: true, - child: Container(key: containerKey, width: 100, height: 100), + child: SizedBox(key: containerKey, width: 100, height: 100), ), ), ), @@ -358,7 +358,7 @@ void main() { }, child: Focus( autofocus: true, - child: Container(key: containerKey, width: 100, height: 100), + child: SizedBox(key: containerKey, width: 100, height: 100), ), ), ), 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 88414f595d..9b2c4326d9 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -271,7 +271,7 @@ void main() { controller: controller, child: Column( children: List.generate(30, (int i) { - return Container( + return SizedBox( height: 200.0, child: Text('Tile $i'), ); @@ -442,14 +442,14 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: SingleChildScrollView( controller: ScrollController(initialScrollOffset: 300.0), child: Column( children: children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 100.0, width: 300.0, child: Text('Tile $i'), @@ -484,7 +484,7 @@ void main() { testWidgets('SingleChildScrollView getOffsetToReveal - up', (WidgetTester tester) async { final List children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 100.0, width: 300.0, child: Text('Tile $i'), @@ -494,7 +494,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: SingleChildScrollView( @@ -536,7 +536,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 300.0, width: 200.0, child: SingleChildScrollView( @@ -544,7 +544,7 @@ void main() { controller: ScrollController(initialScrollOffset: 300.0), child: Row( children: children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 300.0, width: 100.0, child: Text('Tile $i'), @@ -579,7 +579,7 @@ void main() { testWidgets('SingleChildScrollView getOffsetToReveal - left', (WidgetTester tester) async { final List children = List.generate(20, (int i) { - return Container( + return SizedBox( height: 300.0, width: 100.0, child: Text('Tile $i'), @@ -590,7 +590,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 300.0, width: 200.0, child: SingleChildScrollView( @@ -661,7 +661,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 200.0, child: SingleChildScrollView( @@ -798,24 +798,24 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200.0, width: 300.0, child: SingleChildScrollView( controller: outer, child: Column( children: [ - Container( + const SizedBox( height: 200.0, ), - Container( + SizedBox( height: 200.0, width: 300.0, child: SingleChildScrollView( controller: inner, child: Column( children: children = List.generate(10, (int i) { - return Container( + return SizedBox( height: 100.0, width: 300.0, child: Text('$i'), @@ -824,7 +824,7 @@ void main() { ), ), ), - Container( + const SizedBox( height: 200.0, ), ], @@ -934,7 +934,7 @@ void main() { keyboardDismissBehavior: behavior, child: Column( children: focusNodes.map((FocusNode focusNode) { - return Container( + return SizedBox( height: 50, child: TextField(focusNode: focusNode), ); diff --git a/packages/flutter/test/widgets/sliver_appbar_opacity_test.dart b/packages/flutter/test/widgets/sliver_appbar_opacity_test.dart index cb992b41ef..8d7d99d272 100644 --- a/packages/flutter/test/widgets/sliver_appbar_opacity_test.dart +++ b/packages/flutter/test/widgets/sliver_appbar_opacity_test.dart @@ -240,7 +240,7 @@ class _TestWidget extends StatelessWidget { ), SliverList( delegate: SliverChildListDelegate(List.generate(20, (int i) { - return Container( + return SizedBox( child: Text('Tile $i'), height: 100.0, ); diff --git a/packages/flutter/test/widgets/sliver_list_test.dart b/packages/flutter/test/widgets/sliver_list_test.dart index 9e8e1417ca..bc69882434 100644 --- a/packages/flutter/test/widgets/sliver_list_test.dart +++ b/packages/flutter/test/widgets/sliver_list_test.dart @@ -283,14 +283,14 @@ void main() { return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 200, child: ListView( controller: controller, children: [ if (isShow) for (int i = 0; i < 20; i++) - Container( + SizedBox( height: 50, child: Text('Tile $i'), ), @@ -340,7 +340,7 @@ Widget _buildSliverListRenderWidgetChild(List items) { home: Directionality( textDirection: TextDirection.ltr, child: Material( - child: Container( + child: SizedBox( height: 500, child: CustomScrollView( controller: ScrollController(), @@ -372,7 +372,7 @@ Widget _buildSliverList({ return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: viewportHeight, child: CustomScrollView( controller: controller, @@ -380,7 +380,7 @@ Widget _buildSliverList({ SliverList( delegate: SliverChildBuilderDelegate( (BuildContext context, int i) { - return Container( + return SizedBox( key: ValueKey(items[i]), height: itemHeight, child: Text('Tile ${items[i]}'), diff --git a/packages/flutter/test/widgets/sliver_semantics_test.dart b/packages/flutter/test/widgets/sliver_semantics_test.dart index dcf89db700..743f7ddae8 100644 --- a/packages/flutter/test/widgets/sliver_semantics_test.dart +++ b/packages/flutter/test/widgets/sliver_semantics_test.dart @@ -28,7 +28,7 @@ void _tests() { final ScrollController scrollController = ScrollController(); final List listChildren = List.generate(30, (int i) { - return Container( + return SizedBox( height: appBarExpandedHeight, child: Text('Item $i'), ); @@ -293,7 +293,7 @@ void _tests() { ); final List slivers = List.generate(30, (int i) { return SliverToBoxAdapter( - child: Container( + child: SizedBox( height: containerHeight, child: Text('Item $i', textDirection: TextDirection.ltr), ), @@ -380,7 +380,7 @@ void _tests() { final List slivers = List.generate(5, (int i) { return SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 20.0, child: Text('Item $i'), ), @@ -459,7 +459,7 @@ void _tests() { final SemanticsTester semantics = SemanticsTester(tester); final List listChildren = List.generate(10, (int i) { - return Container( + return SizedBox( height: 200.0, child: Text('Item $i', textDirection: TextDirection.ltr), ); @@ -572,7 +572,7 @@ void _tests() { final ScrollController controller = ScrollController(initialScrollOffset: 280.0); final List slivers = List.generate(10, (int i) { return SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 200.0, child: Text('Item $i', textDirection: TextDirection.ltr), ), @@ -681,7 +681,7 @@ void _tests() { final SemanticsTester semantics = SemanticsTester(tester); final List listChildren = List.generate(10, (int i) { - return Container( + return SizedBox( height: 200.0, child: Text('Item $i', textDirection: TextDirection.ltr), ); @@ -797,7 +797,7 @@ void _tests() { final ScrollController controller = ScrollController(initialScrollOffset: 280.0); final List slivers = List.generate(10, (int i) { return SliverToBoxAdapter( - child: Container( + child: SizedBox( height: 200.0, child: Text('Item $i', textDirection: TextDirection.ltr), ), @@ -911,13 +911,13 @@ void _tests() { final ScrollController controller = ScrollController(initialScrollOffset: 280.0); final GlobalKey forwardAppBarKey = GlobalKey(debugLabel: 'forward app bar'); final List forwardChildren = List.generate(10, (int i) { - return Container( + return SizedBox( height: 200.0, child: Text('Forward Item $i', textDirection: TextDirection.ltr), ); }); final List backwardChildren = List.generate(10, (int i) { - return Container( + return SizedBox( height: 200.0, child: Text('Backward Item $i', textDirection: TextDirection.ltr), ); diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart index e149c8fa94..ef2ad43c9f 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart @@ -320,7 +320,7 @@ void main() { ), SliverList( delegate: SliverChildListDelegate(List.generate(20, (int i) { - return Container( + return SizedBox( child: Text('Tile $i'), height: 100.0, ); diff --git a/packages/flutter/test/widgets/slivers_keepalive_test.dart b/packages/flutter/test/widgets/slivers_keepalive_test.dart index c22f0b6fcc..862ba74d5a 100644 --- a/packages/flutter/test/widgets/slivers_keepalive_test.dart +++ b/packages/flutter/test/widgets/slivers_keepalive_test.dart @@ -448,7 +448,7 @@ class _SwitchingChildBuilderTest extends State { return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 100, child: CustomScrollView( cacheExtent: 0, @@ -490,7 +490,7 @@ class _SwitchingChildListTest extends State { return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 100, child: CustomScrollView( cacheExtent: 0, @@ -527,7 +527,7 @@ class _SwitchingSliverListTest extends State { return Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 100, child: CustomScrollView( cacheExtent: 0, diff --git a/packages/flutter/test/widgets/slivers_padding_test.dart b/packages/flutter/test/widgets/slivers_padding_test.dart index 17f857e266..4582c2471a 100644 --- a/packages/flutter/test/widgets/slivers_padding_test.dart +++ b/packages/flutter/test/widgets/slivers_padding_test.dart @@ -394,7 +394,7 @@ void main() { await tester.pumpWidget( listBuilder( (BuildContext context, int index) { - return Container( + return SizedBox( height: 200.0, child: Center( child: Text(index.toString()), @@ -408,7 +408,7 @@ void main() { await tester.pump(); expect( - tester.getRect(find.widgetWithText(Container, '2')), + tester.getRect(find.widgetWithText(SizedBox, '2')), const Rect.fromLTRB(0.0, 100.0, 800.0, 300.0), ); @@ -416,7 +416,7 @@ void main() { await tester.pumpWidget( listBuilder( (BuildContext context, int index) { - return Container( + return SizedBox( height: index == 0 ? 400.0 : 200.0, child: Center( child: Text(index.toString()), @@ -431,7 +431,7 @@ void main() { await tester.pump(); expect( - tester.getRect(find.widgetWithText(Container, '0')), + tester.getRect(find.widgetWithText(SizedBox, '0')), const Rect.fromLTRB(0.0, -200.0, 800.0, 200.0), ); }); diff --git a/packages/flutter/test/widgets/slivers_test.dart b/packages/flutter/test/widgets/slivers_test.dart index 9625708c47..28e329314f 100644 --- a/packages/flutter/test/widgets/slivers_test.dart +++ b/packages/flutter/test/widgets/slivers_test.dart @@ -161,20 +161,20 @@ void main() { slivers: [ SliverList( delegate: SliverChildListDelegate( - [ - Container(height: 22.2, child: const Text('TOP')), - Container(height: 22.2), - Container(height: 22.2), + const [ + SizedBox(height: 22.2, child: Text('TOP')), + SizedBox(height: 22.2), + SizedBox(height: 22.2), ], ), ), SliverFixedExtentList( itemExtent: 22.2, delegate: SliverChildListDelegate( - [ - Container(), - Container(child: const Text('A')), - Container(), + const [ + SizedBox(), + Text('A'), + SizedBox(), ], ), ), @@ -183,19 +183,19 @@ void main() { crossAxisCount: 2, ), delegate: SliverChildListDelegate( - [ - Container(), - Container(child: const Text('B')), - Container(), + const [ + SizedBox(), + Text('B'), + SizedBox(), ], ), ), SliverList( delegate: SliverChildListDelegate( - [ - Container(height: 22.2), - Container(height: 22.2), - Container(height: 22.2, child: const Text('BOTTOM')), + const [ + SizedBox(height: 22.2), + SizedBox(height: 22.2), + SizedBox(height: 22.2, child: Text('BOTTOM')), ], ), ), diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index 9c5d9ee110..516e8ef0f7 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -42,10 +42,10 @@ void main() { await tester.pumpWidget( Stack( alignment: Alignment.topLeft, - children: [ + children: const [ Positioned( left: 10.0, - child: Container( + child: SizedBox( key: key, width: 10.0, height: 10.0, @@ -70,10 +70,10 @@ void main() { await tester.pumpWidget( Stack( alignment: Alignment.topLeft, - children: [ + children: const [ Positioned( right: 10.0, - child: Container( + child: SizedBox( key: key, width: 10.0, height: 10.0, @@ -95,12 +95,12 @@ void main() { testWidgets('Can remove parent data', (WidgetTester tester) async { const Key key = Key('container'); - final Container container = Container(key: key, width: 10.0, height: 10.0); + const SizedBox sizedBox = SizedBox(key: key, width: 10.0, height: 10.0); await tester.pumpWidget( Stack( textDirection: TextDirection.ltr, - children: [ Positioned(left: 10.0, child: container) ], + children: const [ Positioned(left: 10.0, child: sizedBox) ], ), ); Element containerElement = tester.element(find.byKey(key)); @@ -117,7 +117,7 @@ void main() { await tester.pumpWidget( Stack( textDirection: TextDirection.ltr, - children: [ container ], + children: const [ sizedBox ], ), ); containerElement = tester.element(find.byKey(key)); @@ -141,9 +141,9 @@ void main() { child: Center( child: Stack( alignment: Alignment.center, - children: [ - Container(key: child0Key, width: 20.0, height: 20.0), - Container(key: child1Key, width: 10.0, height: 10.0), + children: const [ + SizedBox(key: child0Key, width: 20.0, height: 20.0), + SizedBox(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -164,9 +164,9 @@ void main() { child: Center( child: Stack( alignment: AlignmentDirectional.bottomEnd, - children: [ - Container(key: child0Key, width: 20.0, height: 20.0), - Container(key: child1Key, width: 10.0, height: 10.0), + children: const [ + SizedBox(key: child0Key, width: 20.0, height: 20.0), + SizedBox(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -187,9 +187,9 @@ void main() { child: Center( child: Stack( alignment: Alignment.center, - children: [ - Container(key: child0Key, width: 20.0, height: 20.0), - Container(key: child1Key, width: 10.0, height: 10.0), + children: const [ + SizedBox(key: child0Key, width: 20.0, height: 20.0), + SizedBox(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -210,9 +210,9 @@ void main() { child: Center( child: Stack( alignment: AlignmentDirectional.bottomEnd, - children: [ - Container(key: child0Key, width: 20.0, height: 20.0), - Container(key: child1Key, width: 10.0, height: 10.0), + children: const [ + SizedBox(key: child0Key, width: 20.0, height: 20.0), + SizedBox(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -559,7 +559,7 @@ void main() { Positioned.directional( textDirection: TextDirection.rtl, start: 50.0, - child: Container(key: key, width: 75.0, height: 175.0), + child: SizedBox(key: key, width: 75.0, height: 175.0), ), ], ), @@ -576,7 +576,7 @@ void main() { Positioned.directional( textDirection: TextDirection.ltr, start: 50.0, - child: Container(key: key, width: 75.0, height: 175.0), + child: SizedBox(key: key, width: 75.0, height: 175.0), ), ], ), @@ -595,7 +595,7 @@ void main() { children: [ PositionedDirectional( start: 50.0, - child: Container(key: key, width: 75.0, height: 175.0), + child: SizedBox(key: key, width: 75.0, height: 175.0), ), ], ), @@ -611,7 +611,7 @@ void main() { children: [ PositionedDirectional( start: 50.0, - child: Container(key: key, width: 75.0, height: 175.0), + child: SizedBox(key: key, width: 75.0, height: 175.0), ), ], ), diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index 2c267be952..5bed549971 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -1216,7 +1216,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( height: 100, child: IntrinsicWidth( child: RichText( @@ -1228,9 +1228,9 @@ void main() { alignment: PlaceholderAlignment.top, child: Wrap( direction: Axis.vertical, - children: [ - Container(width: 200, height: 100), - Container(width: 200, height: 30), + children: const [ + SizedBox(width: 200, height: 100), + SizedBox(width: 200, height: 30), ], ), ), @@ -1262,7 +1262,7 @@ Future _pumpTextWidget({ Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: SizedBox( width: 50.0, height: 50.0, child: Text( diff --git a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart index 14b22ce5e7..11a19f5362 100644 --- a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart +++ b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart @@ -19,7 +19,7 @@ void main() { controller: controller, children: List.generate( 10, - (int i) => Container( + (int i) => SizedBox( height: listItemHeight, child: Text('Page$index-Item$i'), ), diff --git a/packages/flutter/test/widgets/transform_test.dart b/packages/flutter/test/widgets/transform_test.dart index 2e362bff5e..f7f27b7129 100644 --- a/packages/flutter/test/widgets/transform_test.dart +++ b/packages/flutter/test/widgets/transform_test.dart @@ -30,7 +30,7 @@ void main() { Positioned( top: 100.0, left: 100.0, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: Transform( @@ -78,7 +78,7 @@ void main() { Positioned( top: 100.0, left: 100.0, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: Transform( @@ -127,7 +127,7 @@ void main() { Positioned( top: 100.0, left: 100.0, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: Transform( @@ -197,7 +197,7 @@ void main() { Positioned( top: 100.0, left: 100.0, - child: Container( + child: SizedBox( width: 100.0, height: 100.0, child: Transform( diff --git a/packages/flutter/test/widgets/transformed_scrollable_test.dart b/packages/flutter/test/widgets/transformed_scrollable_test.dart index efeb696b5e..afa227ebd6 100644 --- a/packages/flutter/test/widgets/transformed_scrollable_test.dart +++ b/packages/flutter/test/widgets/transformed_scrollable_test.dart @@ -18,7 +18,7 @@ void main() { home: Transform.scale( scale: 2.0, child: Center( - child: Container( + child: SizedBox( width: 200, child: ListView.builder( controller: controller, @@ -62,7 +62,7 @@ void main() { home: Transform.scale( scale: 0.5, child: Center( - child: Container( + child: SizedBox( width: 200, child: ListView.builder( controller: controller, @@ -106,7 +106,7 @@ void main() { home: Transform.rotate( angle: math.pi / 2, child: Center( - child: Container( + child: SizedBox( width: 200, child: ListView.builder( controller: controller, @@ -148,7 +148,7 @@ void main() { ..setEntry(3, 2, 0.001) ..rotateX(math.pi / 4), child: Center( - child: Container( + child: SizedBox( width: 200, child: ListView.builder( controller: controller, diff --git a/packages/flutter_driver/test/src/real_tests/extension_test.dart b/packages/flutter_driver/test/src/real_tests/extension_test.dart index 7b6af84015..a3f175fcdd 100644 --- a/packages/flutter_driver/test/src/real_tests/extension_test.dart +++ b/packages/flutter_driver/test/src/real_tests/extension_test.dart @@ -525,8 +525,8 @@ void main() { alignment: Alignment.topLeft, child: Transform.translate( offset: const Offset(40, 30), - child: Container( - key: const ValueKey(1), + child: const SizedBox( + key: ValueKey(1), width: 100, height: 120, ), @@ -560,14 +560,14 @@ void main() { key: const ValueKey('column'), children: [ const Text('Hello1', key: ValueKey('text1')), - Container( + SizedBox( height: 25.0, child: RichText( key: const ValueKey('text2'), text: const TextSpan(text: 'Hello2'), ), ), - Container( + SizedBox( height: 25.0, child: EditableText( key: const ValueKey('text3'), @@ -578,21 +578,21 @@ void main() { backgroundCursorColor: Colors.black, ), ), - Container( + SizedBox( height: 25.0, child: TextField( key: const ValueKey('text4'), controller: TextEditingController(text: 'Hello4'), ), ), - Container( + SizedBox( height: 25.0, child: TextFormField( key: const ValueKey('text5'), controller: TextEditingController(text: 'Hello5'), ), ), - Container( + SizedBox( height: 25.0, child: RichText( key: const ValueKey('text6'), @@ -724,20 +724,20 @@ void main() { await tester.pumpWidget( MaterialApp( home: Center( - child: Container( + child: SizedBox( key: const ValueKey('parent'), height: 100, width: 100, child: Center( child: Row( - children: [ - Container( - key: const ValueKey('leftchild'), + children: const [ + SizedBox( + key: ValueKey('leftchild'), width: 25, height: 25, ), - Container( - key: const ValueKey('righttchild'), + SizedBox( + key: ValueKey('righttchild'), width: 25, height: 25, ), @@ -780,7 +780,7 @@ void main() { Future getAncestorTopLeft() async { final Map arguments = GetOffset(Ancestor( of: ByValueKey('leaf'), - matching: const ByType('Container'), + matching: const ByType('SizedBox'), firstMatchOnly: true, ), OffsetType.topLeft, timeout: const Duration(seconds: 1)).serialize(); final Map response = await driverExtension.call(arguments); @@ -792,18 +792,18 @@ void main() { } await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: Center( - child: Container( + child: SizedBox( height: 200, width: 200, child: Center( - child: Container( + child: SizedBox( height: 100, width: 100, child: Center( - child: Container( - key: const ValueKey('leaf'), + child: SizedBox( + key: ValueKey('leaf'), height: 50, width: 50, ), diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index 1d4d2e922c..b09404dd3a 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -138,10 +138,10 @@ void main() { Semantics( label: 'This is not text', container: true, - child: Container( + child: const SizedBox( width: 200.0, height: 200.0, - child: const Placeholder(), + child: Placeholder(), ), ), )); diff --git a/packages/flutter_test/test/controller_test.dart b/packages/flutter_test/test/controller_test.dart index a96794e825..04a7ed201a 100644 --- a/packages/flutter_test/test/controller_test.dart +++ b/packages/flutter_test/test/controller_test.dart @@ -771,7 +771,7 @@ void main() { home: Scaffold( body: Column( children: [ - Container(height: 200, child: ListView.builder( + SizedBox(height: 200, child: ListView.builder( key: const Key('listView-a'), itemCount: 50, shrinkWrap: true,