From 81bc54be75cb072b26028bac93ff25dc06a216ad Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 20 Dec 2022 14:09:55 -0800 Subject: [PATCH] Enable `use_colored_box` lint (#117370) --- analysis_options.yaml | 2 +- .../complex_layout/lib/src/app.dart | 2 +- .../lib/src/backdrop_filter.dart | 2 +- .../lib/src/post_backdrop_filter.dart | 4 +- .../android_views/lib/wm_integrations.dart | 2 +- .../lib/demo/animation/home.dart | 2 +- .../cupertino/cupertino_navigation_demo.dart | 2 +- .../lib/demo/fortnightly/fortnightly.dart | 2 +- .../lib/demo/material/backdrop_demo.dart | 2 +- .../lib/demo/material/leave_behind_demo.dart | 4 +- .../lib/nested_view_event_page.dart | 2 +- dev/manual_tests/lib/star_border.dart | 2 +- dev/manual_tests/lib/text.dart | 12 +++--- .../cupertino_context_menu.0.dart | 4 +- .../api/lib/material/divider/divider.0.dart | 8 ++-- ...ist_view.build_default_drag_handles.0.dart | 2 +- .../painting/star_border/star_border.0.dart | 2 +- .../animated_size/animated_size.0.dart | 2 +- .../animated_switcher.0.dart | 2 +- .../api/lib/widgets/basic/listener.0.dart | 2 +- .../api/lib/widgets/basic/mouse_region.0.dart | 2 +- .../focus_manager/focus_node.unfocus.0.dart | 2 +- .../focus_traversal_group.0.dart | 2 +- .../animated_fractionally_sized_box.0.dart | 6 +-- .../animated_positioned.0.dart | 4 +- .../transitions/align_transition.0.dart | 2 +- .../decorated_box_transition.0.dart | 2 +- .../transitions/fade_transition.0.dart | 2 +- .../test/material/divider/divider.0_test.dart | 4 +- .../flutter/lib/src/animation/animation.dart | 8 ++-- .../flutter/lib/src/cupertino/dialog.dart | 4 +- .../lib/src/material/checkbox_list_tile.dart | 2 +- .../flutter/lib/src/material/list_tile.dart | 4 +- .../src/material/material_state_mixin.dart | 4 +- .../flutter/lib/src/material/popup_menu.dart | 2 +- .../lib/src/material/radio_list_tile.dart | 2 +- .../lib/src/material/switch_list_tile.dart | 2 +- packages/flutter/lib/src/widgets/basic.dart | 2 +- .../flutter/lib/src/widgets/framework.dart | 2 +- .../flutter/lib/src/widgets/page_view.dart | 4 +- .../cupertino/activity_indicator_test.dart | 24 +++++------ .../test/cupertino/magnifier_test.dart | 2 +- .../flutter/test/material/dropdown_test.dart | 2 +- .../flutter/test/material/magnifier_test.dart | 17 ++++---- .../material/material_state_mixin_test.dart | 7 ++-- packages/flutter/test/material/tabs_test.dart | 2 +- .../test/material/text_field_test.dart | 2 +- .../flutter/test/rendering/viewport_test.dart | 2 +- .../animated_image_filtered_repaint_test.dart | 4 +- .../animated_opacity_repaint_test.dart | 6 +-- packages/flutter/test/widgets/clip_test.dart | 40 +++++++++---------- .../draggable_scrollable_sheet_test.dart | 2 +- .../editable_text_show_on_screen_test.dart | 2 +- .../test/widgets/editable_text_test.dart | 2 +- packages/flutter/test/widgets/flex_test.dart | 2 +- .../flutter/test/widgets/framework_test.dart | 13 +++--- .../flutter/test/widgets/grid_view_test.dart | 4 +- .../flutter/test/widgets/list_view_test.dart | 4 +- .../test/widgets/lookup_boundary_test.dart | 5 +++ .../flutter/test/widgets/navigator_test.dart | 12 +++--- .../test/widgets/opacity_repaint_test.dart | 20 +++++----- .../test/widgets/page_transitions_test.dart | 6 +-- .../test/widgets/reparent_state_test.dart | 12 +++--- ...parent_state_with_layout_builder_test.dart | 12 +++--- .../flutter/test/widgets/rich_text_test.dart | 2 +- .../test/widgets/scrollable_fling_test.dart | 2 +- .../widgets/sliver_fill_remaining_test.dart | 6 +-- .../widgets/sliver_fill_viewport_test.dart | 6 +-- .../test/widgets/slivers_evil_test.dart | 12 +++--- .../flutter/test/widgets/syncing_test.dart | 14 +++---- .../test/widgets/widget_inspector_test.dart | 18 ++++----- packages/flutter/test/widgets/wrap_test.dart | 4 +- 72 files changed, 198 insertions(+), 194 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 796d663a4f67..c017556d9a8a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -221,7 +221,7 @@ linter: - unrelated_type_equality_checks - unsafe_html - use_build_context_synchronously - # - use_colored_box # not yet tested + - use_colored_box # - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding) - use_enums - use_full_hex_values_for_flutter_colors diff --git a/dev/benchmarks/complex_layout/lib/src/app.dart b/dev/benchmarks/complex_layout/lib/src/app.dart index 21c03d6d807c..df6bccfcc56d 100644 --- a/dev/benchmarks/complex_layout/lib/src/app.dart +++ b/dev/benchmarks/complex_layout/lib/src/app.dart @@ -524,7 +524,7 @@ class ItemGalleryBox extends StatelessWidget { child: Column( children: [ Expanded( - child: Container( + child: ColoredBox( color: Theme.of(context).primaryColor, child: Center( child: Text(tabName, style: Theme.of(context).textTheme.headlineSmall!.copyWith(color: Colors.white)), diff --git a/dev/benchmarks/macrobenchmarks/lib/src/backdrop_filter.dart b/dev/benchmarks/macrobenchmarks/lib/src/backdrop_filter.dart index 7fa1133b18be..0fa06aa89ab4 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/backdrop_filter.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/backdrop_filter.dart @@ -91,7 +91,7 @@ class _BackdropFilterPageState extends State with TickerProv child: addBlur(grid(txt, 17, 5), _blurGroup), ), const SizedBox(height: 20), - Container( + ColoredBox( color: Colors.white, child:Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/dev/benchmarks/macrobenchmarks/lib/src/post_backdrop_filter.dart b/dev/benchmarks/macrobenchmarks/lib/src/post_backdrop_filter.dart index b17005c0bca7..8904ce22f04b 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/post_backdrop_filter.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/post_backdrop_filter.dart @@ -74,9 +74,9 @@ class _PostBackdropFilterPageState extends State with Ti ), getConditionalBackdrop(), RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, - child:Row( + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('Include BackdropFilter:'), diff --git a/dev/integration_tests/android_views/lib/wm_integrations.dart b/dev/integration_tests/android_views/lib/wm_integrations.dart index 96371a849160..29ce12d13235 100644 --- a/dev/integration_tests/android_views/lib/wm_integrations.dart +++ b/dev/integration_tests/android_views/lib/wm_integrations.dart @@ -88,7 +88,7 @@ class WindowManagerBodyState extends State { Widget _statusWidget() { assert(_lastTestStatus != _LastTestStatus.pending); final String? message = _lastTestStatus == _LastTestStatus.success ? 'Success' : lastError; - return Container( + return ColoredBox( color: _lastTestStatus == _LastTestStatus.success ? Colors.green : Colors.red, child: Text( message!, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart b/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart index 3803e9ea1551..ce08027c6141 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/animation/home.dart @@ -520,7 +520,7 @@ class _AnimationDemoHomeState extends State { final List headings = []; for (int index = 0; index < allSections.length; index++) { - headings.add(Container( + headings.add(ColoredBox( color: _kAppBackgroundColor, child: ClipRect( child: _AllSectionsView( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart index 7bc0fa9bcfa7..b00914d7bbc1 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart @@ -214,7 +214,7 @@ class Tab1RowItem extends StatelessWidget { ), )); }, - child: Container( + child: ColoredBox( color: CupertinoDynamicColor.resolve(CupertinoColors.systemBackground, context), child: SafeArea( top: false, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart b/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart index 789b6f655666..328e9a9a1ed6 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/fortnightly/fortnightly.dart @@ -95,7 +95,7 @@ over water meant for the whole central valley of California? The story will shoc return SingleChildScrollView( child: SafeArea( top: false, - child: Container( + child: ColoredBox( color: Theme.of(context).colorScheme.surface, child: Column( children: [ diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart index 5623ab17290c..ded1a7b05e56 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/backdrop_demo.dart @@ -358,7 +358,7 @@ class _BackdropDemoState extends State with SingleTickerProviderSt ); }).toList(); - return Container( + return ColoredBox( key: _backdropKey, color: theme.primaryColor, child: Stack( diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart index e6e9035d508b..1bae0d46d55a 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -243,7 +243,7 @@ class _LeaveBehindListItem extends StatelessWidget { } return false; }, - background: Container( + background: ColoredBox( color: theme.primaryColor, child: const Center( child: ListTile( @@ -251,7 +251,7 @@ class _LeaveBehindListItem extends StatelessWidget { ), ), ), - secondaryBackground: Container( + secondaryBackground: ColoredBox( color: theme.primaryColor, child: const Center( child: ListTile( diff --git a/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart b/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart index c60f9b39c214..dffbe73853fe 100644 --- a/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart +++ b/dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart @@ -122,7 +122,7 @@ class NestedViewEventBodyState extends State { Widget _statusWidget() { assert(_lastTestStatus != _LastTestStatus.pending); final String message = _lastTestStatus == _LastTestStatus.success ? 'Success' : lastError!; - return Container( + return ColoredBox( color: _lastTestStatus == _LastTestStatus.success ? Colors.green : Colors.red, child: Text( message, diff --git a/dev/manual_tests/lib/star_border.dart b/dev/manual_tests/lib/star_border.dart index dafc353fa9db..172bb9e950c0 100644 --- a/dev/manual_tests/lib/star_border.dart +++ b/dev/manual_tests/lib/star_border.dart @@ -66,7 +66,7 @@ class _MyHomePageState extends State { ), body: Column( children: [ - Container(color: Colors.grey.shade200, child: Options(_model)), + ColoredBox(color: Colors.grey.shade200, child: Options(_model)), Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, diff --git a/dev/manual_tests/lib/text.dart b/dev/manual_tests/lib/text.dart index 2040cefc3658..b46c795b809f 100644 --- a/dev/manual_tests/lib/text.dart +++ b/dev/manual_tests/lib/text.dart @@ -508,7 +508,7 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.black, child: Column( children: [ @@ -577,7 +577,7 @@ class _UnderlinesState extends State { @override Widget build(BuildContext context) { final Size size = MediaQuery.of(context).size; - return Container( + return ColoredBox( color: Colors.black, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -680,7 +680,7 @@ class _FallbackState extends State { @override Widget build(BuildContext context) { final Size size = MediaQuery.of(context).size; - return Container( + return ColoredBox( color: Colors.black, child: Column( children: [ @@ -754,7 +754,7 @@ class Bidi extends StatefulWidget { class _BidiState extends State { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.black, child: ListView( padding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 20.0), @@ -862,7 +862,7 @@ class _ZalgoState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.black, child: Column( children: [ @@ -988,7 +988,7 @@ class _PaintingState extends State with SingleTickerProviderStateMixin @override Widget build(BuildContext context) { final Size size = MediaQuery.of(context).size; - return Container( + return ColoredBox( color: Colors.black, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/examples/api/lib/cupertino/context_menu/cupertino_context_menu.0.dart b/examples/api/lib/cupertino/context_menu/cupertino_context_menu.0.dart index 295adfb99b62..2324397c9694 100644 --- a/examples/api/lib/cupertino/context_menu/cupertino_context_menu.0.dart +++ b/examples/api/lib/cupertino/context_menu/cupertino_context_menu.0.dart @@ -67,9 +67,9 @@ class ContextMenuExample extends StatelessWidget { child: const Text('Delete'), ), ], - child: Container( + child: const ColoredBox( color: CupertinoColors.systemYellow, - child: const FlutterLogo(size: 500.0), + child: FlutterLogo(size: 500.0), ), ), ), diff --git a/examples/api/lib/material/divider/divider.0.dart b/examples/api/lib/material/divider/divider.0.dart index 6672379269d2..973b4ce32328 100644 --- a/examples/api/lib/material/divider/divider.0.dart +++ b/examples/api/lib/material/divider/divider.0.dart @@ -30,10 +30,10 @@ class DividerExample extends StatelessWidget { return Center( child: Column( children: [ - Expanded( - child: Container( + const Expanded( + child: ColoredBox( color: Colors.amber, - child: const Center( + child: Center( child: Text('Above'), ), ), @@ -59,7 +59,7 @@ class DividerExample extends StatelessWidget { ), ), Expanded( - child: Container( + child: ColoredBox( color: Theme.of(context).colorScheme.primary, child: const Center( child: Text('Below'), diff --git a/examples/api/lib/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart b/examples/api/lib/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart index 662bfe4e6715..77db7674f038 100644 --- a/examples/api/lib/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart +++ b/examples/api/lib/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart @@ -42,7 +42,7 @@ class _ReorderableExampleState extends State { buildDefaultDragHandles: false, children: [ for (int index = 0; index < _items.length; index++) - Container( + ColoredBox( key: Key('$index'), color: _items[index].isOdd ? oddItemColor : evenItemColor, child: Row( diff --git a/examples/api/lib/painting/star_border/star_border.0.dart b/examples/api/lib/painting/star_border/star_border.0.dart index 34d3669c4b09..a1a5e51982e2 100644 --- a/examples/api/lib/painting/star_border/star_border.0.dart +++ b/examples/api/lib/painting/star_border/star_border.0.dart @@ -66,7 +66,7 @@ class _StarBorderExampleState extends State { ), child: ListView( children: [ - Container( + ColoredBox( color: Colors.grey.shade200, child: Options(_model), ), diff --git a/examples/api/lib/widgets/animated_size/animated_size.0.dart b/examples/api/lib/widgets/animated_size/animated_size.0.dart index 6aba8a2af7fe..cd818a4a8c2f 100644 --- a/examples/api/lib/widgets/animated_size/animated_size.0.dart +++ b/examples/api/lib/widgets/animated_size/animated_size.0.dart @@ -49,7 +49,7 @@ class _MyStatefulWidgetState extends State { Widget build(BuildContext context) { return GestureDetector( onTap: () => _updateSize(), - child: Container( + child: ColoredBox( color: Colors.amberAccent, child: AnimatedSize( curve: Curves.easeIn, diff --git a/examples/api/lib/widgets/animated_switcher/animated_switcher.0.dart b/examples/api/lib/widgets/animated_switcher/animated_switcher.0.dart index b10abcb4d948..97871088bdc5 100644 --- a/examples/api/lib/widgets/animated_switcher/animated_switcher.0.dart +++ b/examples/api/lib/widgets/animated_switcher/animated_switcher.0.dart @@ -34,7 +34,7 @@ class _MyStatefulWidgetState extends State { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/examples/api/lib/widgets/basic/listener.0.dart b/examples/api/lib/widgets/basic/listener.0.dart index b0f6236f47b2..3d763e31adc1 100644 --- a/examples/api/lib/widgets/basic/listener.0.dart +++ b/examples/api/lib/widgets/basic/listener.0.dart @@ -69,7 +69,7 @@ class _MyStatefulWidgetState extends State { onPointerDown: _incrementDown, onPointerMove: _updateLocation, onPointerUp: _incrementUp, - child: Container( + child: ColoredBox( color: Colors.lightBlueAccent, child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/examples/api/lib/widgets/basic/mouse_region.0.dart b/examples/api/lib/widgets/basic/mouse_region.0.dart index 8402bb48d886..04727520194c 100644 --- a/examples/api/lib/widgets/basic/mouse_region.0.dart +++ b/examples/api/lib/widgets/basic/mouse_region.0.dart @@ -67,7 +67,7 @@ class _MyStatefulWidgetState extends State { onEnter: _incrementEnter, onHover: _updateLocation, onExit: _incrementExit, - child: Container( + child: ColoredBox( color: Colors.lightBlueAccent, child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart b/examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart index 3278812cbb22..07d5c69243a9 100644 --- a/examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart +++ b/examples/api/lib/widgets/focus_manager/focus_node.unfocus.0.dart @@ -36,7 +36,7 @@ class _MyStatefulWidgetState extends State { @override Widget build(BuildContext context) { return Material( - child: Container( + child: ColoredBox( color: Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart b/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart index c06cddd97c8f..4c45823c4366 100644 --- a/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart +++ b/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart @@ -125,7 +125,7 @@ class MyStatelessWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.white, child: FocusTraversalGroup( policy: OrderedTraversalPolicy(), diff --git a/examples/api/lib/widgets/implicit_animations/animated_fractionally_sized_box.0.dart b/examples/api/lib/widgets/implicit_animations/animated_fractionally_sized_box.0.dart index 89f912808c6d..6c0ec1301334 100644 --- a/examples/api/lib/widgets/implicit_animations/animated_fractionally_sized_box.0.dart +++ b/examples/api/lib/widgets/implicit_animations/animated_fractionally_sized_box.0.dart @@ -47,7 +47,7 @@ class _MyStatefulWidgetState extends State { child: SizedBox( width: 200, height: 200, - child: Container( + child: ColoredBox( color: Colors.red, child: AnimatedFractionallySizedBox( widthFactor: selected ? 0.25 : 0.75, @@ -55,9 +55,9 @@ class _MyStatefulWidgetState extends State { alignment: selected ? Alignment.topLeft : Alignment.bottomRight, duration: const Duration(seconds: 1), curve: Curves.fastOutSlowIn, - child: Container( + child: const ColoredBox( color: Colors.blue, - child: const FlutterLogo(size: 75), + child: FlutterLogo(size: 75), ), ), ), diff --git a/examples/api/lib/widgets/implicit_animations/animated_positioned.0.dart b/examples/api/lib/widgets/implicit_animations/animated_positioned.0.dart index 19207f285fee..c43715d67346 100644 --- a/examples/api/lib/widgets/implicit_animations/animated_positioned.0.dart +++ b/examples/api/lib/widgets/implicit_animations/animated_positioned.0.dart @@ -56,9 +56,9 @@ class _MyStatefulWidgetState extends State { selected = !selected; }); }, - child: Container( + child: const ColoredBox( color: Colors.blue, - child: const Center(child: Text('Tap me')), + child: Center(child: Text('Tap me')), ), ), ), diff --git a/examples/api/lib/widgets/transitions/align_transition.0.dart b/examples/api/lib/widgets/transitions/align_transition.0.dart index 1ffb8adbec77..e1052c7a7544 100644 --- a/examples/api/lib/widgets/transitions/align_transition.0.dart +++ b/examples/api/lib/widgets/transitions/align_transition.0.dart @@ -57,7 +57,7 @@ class _MyStatefulWidgetState extends State @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.white, child: AlignTransition( alignment: _animation, diff --git a/examples/api/lib/widgets/transitions/decorated_box_transition.0.dart b/examples/api/lib/widgets/transitions/decorated_box_transition.0.dart index d49c748b6e7a..8d7943e69401 100644 --- a/examples/api/lib/widgets/transitions/decorated_box_transition.0.dart +++ b/examples/api/lib/widgets/transitions/decorated_box_transition.0.dart @@ -70,7 +70,7 @@ class _MyStatefulWidgetState extends State @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.white, child: Center( child: DecoratedBoxTransition( diff --git a/examples/api/lib/widgets/transitions/fade_transition.0.dart b/examples/api/lib/widgets/transitions/fade_transition.0.dart index ea37b132cd88..8ba5efa58c30 100644 --- a/examples/api/lib/widgets/transitions/fade_transition.0.dart +++ b/examples/api/lib/widgets/transitions/fade_transition.0.dart @@ -50,7 +50,7 @@ class _MyStatefulWidgetState extends State @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.white, child: FadeTransition( opacity: _animation, diff --git a/examples/api/test/material/divider/divider.0_test.dart b/examples/api/test/material/divider/divider.0_test.dart index 825f0cbcc0a2..9234d5445ac5 100644 --- a/examples/api/test/material/divider/divider.0_test.dart +++ b/examples/api/test/material/divider/divider.0_test.dart @@ -18,8 +18,8 @@ void main() { expect(find.byType(Divider), findsOneWidget); - // Divider is positioned horizintally. - final Offset container = tester.getBottomLeft(find.byType(Container).first); + // Divider is positioned horizontally. + final Offset container = tester.getBottomLeft(find.byType(ColoredBox).first); expect(container.dy, tester.getTopLeft(find.byType(Divider)).dy); final Offset subheader = tester.getTopLeft(find.text('Subheader')); diff --git a/packages/flutter/lib/src/animation/animation.dart b/packages/flutter/lib/src/animation/animation.dart index 31b359d754be..2b512f14bd64 100644 --- a/packages/flutter/lib/src/animation/animation.dart +++ b/packages/flutter/lib/src/animation/animation.dart @@ -81,9 +81,9 @@ abstract class Animation extends Listenable implements ValueListenable { /// final double opacity = (value / 1000).clamp(0, 1); /// return Opacity(opacity: opacity, child: child); /// }, - /// child: Container( + /// child: const ColoredBox( /// color: Colors.red, - /// child: const Text('Hello, Animation'), + /// child: Text('Hello, Animation'), /// ), /// ); /// } @@ -100,9 +100,9 @@ abstract class Animation extends Listenable implements ValueListenable { /// opacity: Animation.fromValueListenable(_scrollPosition, transformer: (double value) { /// return (value / 1000).clamp(0, 1); /// }), - /// child: Container( + /// child: const ColoredBox( /// color: Colors.red, - /// child: const Text('Hello, Animation'), + /// child: Text('Hello, Animation'), /// ), /// ); /// } diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index ddd491caef05..6735f5c54199 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -289,7 +289,7 @@ class CupertinoAlertDialog extends StatelessWidget { ), ]; - return Container( + return ColoredBox( color: CupertinoDynamicColor.resolve(_kDialogColor, context), child: Column( mainAxisSize: MainAxisSize.min, @@ -555,7 +555,7 @@ class CupertinoActionSheet extends StatelessWidget { content.add(Flexible(child: titleSection)); } - return Container( + return ColoredBox( color: CupertinoDynamicColor.resolve(_kActionSheetBackgroundColor, context), child: Column( mainAxisSize: MainAxisSize.min, diff --git a/packages/flutter/lib/src/material/checkbox_list_tile.dart b/packages/flutter/lib/src/material/checkbox_list_tile.dart index 623e6008014b..e4923661b3cc 100644 --- a/packages/flutter/lib/src/material/checkbox_list_tile.dart +++ b/packages/flutter/lib/src/material/checkbox_list_tile.dart @@ -50,7 +50,7 @@ import 'theme_data.dart'; /// /// {@tool snippet} /// ```dart -/// Container( +/// ColoredBox( /// color: Colors.green, /// child: Material( /// child: CheckboxListTile( diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index cde75dc701ac..65f63c3a8fec 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -100,9 +100,9 @@ enum ListTileControlAffinity { /// /// {@tool snippet} /// ```dart -/// Container( +/// const ColoredBox( /// color: Colors.green, -/// child: const Material( +/// child: Material( /// child: ListTile( /// title: Text('ListTile with red background'), /// tileColor: Colors.red, diff --git a/packages/flutter/lib/src/material/material_state_mixin.dart b/packages/flutter/lib/src/material/material_state_mixin.dart index 2a8d9de2aff0..5b9b23d2f1e5 100644 --- a/packages/flutter/lib/src/material/material_state_mixin.dart +++ b/packages/flutter/lib/src/material/material_state_mixin.dart @@ -38,7 +38,7 @@ import 'material_state.dart'; /// Widget build(BuildContext context) { /// return InkWell( /// onFocusChange: updateMaterialState(MaterialState.focused), -/// child: Container( +/// child: ColoredBox( /// color: widget.color.resolve(materialStates), /// child: widget.child, /// ), @@ -88,7 +88,7 @@ mixin MaterialStateMixin on State { /// class MyWidgetState extends State with MaterialStateMixin { /// @override /// Widget build(BuildContext context) { - /// return Container( + /// return ColoredBox( /// color: isPressed ? Colors.black : Colors.white, /// child: InkWell( /// onHighlightChanged: updateMaterialState( diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 0e2645052639..f61d8b065ddd 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -574,7 +574,7 @@ class _PopupMenu extends StatelessWidget { ); Widget item = route.items[i]; if (route.initialValue != null && route.items[i].represents(route.initialValue)) { - item = Container( + item = ColoredBox( color: Theme.of(context).highlightColor, child: item, ); diff --git a/packages/flutter/lib/src/material/radio_list_tile.dart b/packages/flutter/lib/src/material/radio_list_tile.dart index 7b54f05a9afa..2e39b837815d 100644 --- a/packages/flutter/lib/src/material/radio_list_tile.dart +++ b/packages/flutter/lib/src/material/radio_list_tile.dart @@ -53,7 +53,7 @@ import 'theme_data.dart'; /// /// {@tool snippet} /// ```dart -/// Container( +/// ColoredBox( /// color: Colors.green, /// child: Material( /// child: RadioListTile( diff --git a/packages/flutter/lib/src/material/switch_list_tile.dart b/packages/flutter/lib/src/material/switch_list_tile.dart index a3216e9ce156..51ee37ac2b91 100644 --- a/packages/flutter/lib/src/material/switch_list_tile.dart +++ b/packages/flutter/lib/src/material/switch_list_tile.dart @@ -57,7 +57,7 @@ enum _SwitchListTileType { material, adaptive } /// /// {@tool snippet} /// ```dart -/// Container( +/// ColoredBox( /// color: Colors.green, /// child: Material( /// child: SwitchListTile( diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 50ffb0c0a104..2107e420fe4a 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -1274,7 +1274,7 @@ class PhysicalShape extends SingleChildRenderObjectWidget { /// top right corner pinned to its original position. /// /// ```dart -/// Container( +/// ColoredBox( /// color: Colors.black, /// child: Transform( /// alignment: Alignment.topRight, diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 6aa7ba300e1a..6fbd5fd38d34 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -501,7 +501,7 @@ abstract class Widget extends DiagnosticableTree { /// /// @override /// Widget build(BuildContext context) { -/// return Container(color: color, child: child); +/// return ColoredBox(color: color, child: child); /// } /// } /// ``` diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index ee96f5f98403..f8ef1c1cfa64 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -68,7 +68,7 @@ import 'viewport.dart'; /// body: PageView( /// controller: _pageController, /// children: [ -/// Container( +/// ColoredBox( /// color: Colors.red, /// child: Center( /// child: ElevatedButton( @@ -85,7 +85,7 @@ import 'viewport.dart'; /// ), /// ), /// ), -/// Container( +/// ColoredBox( /// color: Colors.blue, /// child: Center( /// child: ElevatedButton( diff --git a/packages/flutter/test/cupertino/activity_indicator_test.dart b/packages/flutter/test/cupertino/activity_indicator_test.dart index c23cbe7c8571..2b6025d8aea5 100644 --- a/packages/flutter/test/cupertino/activity_indicator_test.dart +++ b/packages/flutter/test/cupertino/activity_indicator_test.dart @@ -37,9 +37,9 @@ void main() { data: const MediaQueryData(), child: RepaintBoundary( key: key, - child: Container( + child: const ColoredBox( color: CupertinoColors.white, - child: const CupertinoActivityIndicator( + child: CupertinoActivityIndicator( animating: false, radius: 35, ), @@ -60,9 +60,9 @@ void main() { data: const MediaQueryData(platformBrightness: Brightness.dark), child: RepaintBoundary( key: key, - child: Container( + child: const ColoredBox( color: CupertinoColors.black, - child: const CupertinoActivityIndicator( + child: CupertinoActivityIndicator( animating: false, radius: 35, ), @@ -84,9 +84,9 @@ void main() { Center( child: RepaintBoundary( key: key, - child: Container( + child: const ColoredBox( color: CupertinoColors.white, - child: const CupertinoActivityIndicator.partiallyRevealed( + child: CupertinoActivityIndicator.partiallyRevealed( progress: 0, ), ), @@ -106,9 +106,9 @@ void main() { Center( child: RepaintBoundary( key: key, - child: Container( + child: const ColoredBox( color: CupertinoColors.white, - child: const CupertinoActivityIndicator.partiallyRevealed( + child: CupertinoActivityIndicator.partiallyRevealed( progress: 0.5, ), ), @@ -128,9 +128,9 @@ void main() { Center( child: RepaintBoundary( key: key, - child: Container( + child: const ColoredBox( color: CupertinoColors.white, - child: const CupertinoActivityIndicator.partiallyRevealed(), + child: CupertinoActivityIndicator.partiallyRevealed(), ), ), ), @@ -165,9 +165,9 @@ void main() { Center( child: RepaintBoundary( key: key, - child: Container( + child: const ColoredBox( color: CupertinoColors.white, - child: const CupertinoActivityIndicator( + child: CupertinoActivityIndicator( animating: false, color: Color(0xFF5D3FD3), radius: 100, diff --git a/packages/flutter/test/cupertino/magnifier_test.dart b/packages/flutter/test/cupertino/magnifier_test.dart index 0a7e5e31eb21..6b2ee60febd9 100644 --- a/packages/flutter/test/cupertino/magnifier_test.dart +++ b/packages/flutter/test/cupertino/magnifier_test.dart @@ -52,7 +52,7 @@ void main() { final Key outerKey = UniqueKey(); await tester.pumpWidget( - Container( + ColoredBox( key: outerKey, color: const Color.fromARGB(255, 0, 255, 179), child: MaterialApp( diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index 0dde57e26c4d..69dd64c3dc74 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -208,7 +208,7 @@ Widget buildDropdownWithHint({ selectedItemBuilder: enableSelectedItemBuilder ? (BuildContext context) { return menuItems.map((String item) { - return Container( + return ColoredBox( color: const Color(0xff00ff00), child: Text(item), ); diff --git a/packages/flutter/test/material/magnifier_test.dart b/packages/flutter/test/material/magnifier_test.dart index e777c7f26963..4bee8a555312 100644 --- a/packages/flutter/test/material/magnifier_test.dart +++ b/packages/flutter/test/material/magnifier_test.dart @@ -119,17 +119,18 @@ void main() { )); await tester.pumpWidget( - Container( + ColoredBox( color: const Color.fromARGB(255, 0, 255, 179), child: MaterialApp( home: Center( - child: Container( - key: textField, - width: 10, - height: 10, - color: Colors.red, - child: const Placeholder(), - )), + child: Container( + key: textField, + width: 10, + height: 10, + color: Colors.red, + child: const Placeholder(), + ), + ), ), ), ); diff --git a/packages/flutter/test/material/material_state_mixin_test.dart b/packages/flutter/test/material/material_state_mixin_test.dart index a5e9a56a73dd..be13d84dcd28 100644 --- a/packages/flutter/test/material/material_state_mixin_test.dart +++ b/packages/flutter/test/material/material_state_mixin_test.dart @@ -58,7 +58,7 @@ class _MyWidgetState extends State<_MyWidget> with MaterialStateMixin { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( key: key, color: widget.evaluator(this) ? trueColor : falseColor, child: _InnerWidget( @@ -70,18 +70,17 @@ class _MyWidgetState extends State<_MyWidget> with MaterialStateMixin { } void main() { - Future verify(WidgetTester tester, Widget widget, StreamController controller,) async { await tester.pumpWidget(MaterialApp(home: Scaffold(body: widget))); // Set the value to True controller.sink.add(true); await tester.pumpAndSettle(); - expect(tester.widget(find.byKey(key)).color, trueColor); + expect(tester.widget(find.byKey(key)).color, trueColor); // Set the value to False controller.sink.add(false); await tester.pumpAndSettle(); - expect(tester.widget(find.byKey(key)).color, falseColor); + expect(tester.widget(find.byKey(key)).color, falseColor); } testWidgets('MaterialState.pressed is tracked', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index c6de82ee98b5..87222add008b 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -78,7 +78,7 @@ class _NestedTabBarContainer extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return ColoredBox( color: Colors.blue, child: Column( children: [ diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 1c4d97e3923a..5d8cc36bd7af 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -11639,7 +11639,7 @@ void main() { await tester.pumpWidget(MaterialApp( home: Scaffold( - body: Container( + body: ColoredBox( color: Colors.grey, child: Center( child: Container( diff --git a/packages/flutter/test/rendering/viewport_test.dart b/packages/flutter/test/rendering/viewport_test.dart index 67b98975247e..fcf683382388 100644 --- a/packages/flutter/test/rendering/viewport_test.dart +++ b/packages/flutter/test/rendering/viewport_test.dart @@ -1874,7 +1874,7 @@ void main() { textDirection: TextDirection.ltr, child: MediaQuery( data: const MediaQueryData(), - child: Container( + child: ColoredBox( color: const Color(0xFF000000), child: Column( children: [ diff --git a/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart b/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart index afeecc8ad716..0ccd25107435 100644 --- a/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart +++ b/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart @@ -12,7 +12,7 @@ void main() { testWidgets('ImageFiltered avoids repainting child as it animates', (WidgetTester tester) async { RenderTestObject.paintCount = 0; await tester.pumpWidget( - Container( + ColoredBox( color: Colors.red, child: ImageFiltered( imageFilter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), @@ -24,7 +24,7 @@ void main() { expect(RenderTestObject.paintCount, 1); await tester.pumpWidget( - Container( + ColoredBox( color: Colors.red, child: ImageFiltered( imageFilter: ImageFilter.blur(sigmaX: 6, sigmaY: 6), diff --git a/packages/flutter/test/widgets/animated_opacity_repaint_test.dart b/packages/flutter/test/widgets/animated_opacity_repaint_test.dart index 425ab6bca6f2..d3ce05edd293 100644 --- a/packages/flutter/test/widgets/animated_opacity_repaint_test.dart +++ b/packages/flutter/test/widgets/animated_opacity_repaint_test.dart @@ -12,7 +12,7 @@ void main() { final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1)); final Tween opacityTween = Tween(begin: 0, end: 1); await tester.pumpWidget( - Container( + ColoredBox( color: Colors.red, child: FadeTransition( opacity: controller.drive(opacityTween), @@ -45,7 +45,7 @@ void main() { final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1)); final Tween opacityTween = Tween(begin: 0, end: 0.99); // Layer is dropped at 1 await tester.pumpWidget( - Container( + ColoredBox( color: Colors.red, child: FadeTransition( opacity: controller.drive(opacityTween), @@ -78,7 +78,7 @@ void main() { final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1)); final Tween opacityTween = Tween(begin: 0.99, end: 0); await tester.pumpWidget( - Container( + ColoredBox( color: Colors.red, child: FadeTransition( opacity: controller.drive(opacityTween), diff --git a/packages/flutter/test/widgets/clip_test.dart b/packages/flutter/test/widgets/clip_test.dart index 8e3b656ee466..6f62675f9f78 100644 --- a/packages/flutter/test/widgets/clip_test.dart +++ b/packages/flutter/test/widgets/clip_test.dart @@ -360,7 +360,7 @@ void main() { await tester.pumpWidget( Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -370,9 +370,9 @@ void main() { child: Transform.rotate( angle: 1.0, // radians child: ClipRect( - child: Container( + child: ColoredBox( color: Colors.red, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( @@ -442,7 +442,7 @@ void main() { await tester.pumpWidget( Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -458,9 +458,9 @@ void main() { bottomLeft: Radius.elliptical(2.5, 12.0), bottomRight: Radius.elliptical(15.0, 6.0), ), - child: Container( + child: ColoredBox( color: Colors.red, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( @@ -491,7 +491,7 @@ void main() { await tester.pumpWidget( Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -501,9 +501,9 @@ void main() { child: Transform.rotate( angle: 1.0, // radians child: ClipOval( - child: Container( + child: ColoredBox( color: Colors.red, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( @@ -534,7 +534,7 @@ void main() { await tester.pumpWidget( Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -549,9 +549,9 @@ void main() { borderRadius: BorderRadius.all(Radius.circular(20.0)), ), ), - child: Container( + child: ColoredBox( color: Colors.red, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( @@ -581,7 +581,7 @@ void main() { Center genPhysicalModel(Clip clipBehavior) { return Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -594,7 +594,7 @@ void main() { borderRadius: const BorderRadius.all(Radius.circular(20.0)), color: Colors.red, clipBehavior: clipBehavior, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( @@ -645,7 +645,7 @@ void main() { await tester.pumpWidget( Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -657,7 +657,7 @@ void main() { child: PhysicalModel( borderRadius: const BorderRadius.all(Radius.circular(20.0)), color: Colors.red, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( @@ -686,7 +686,7 @@ void main() { Center genPhysicalShape(Clip clipBehavior) { return Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -703,7 +703,7 @@ void main() { ), clipBehavior: clipBehavior, color: Colors.red, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( @@ -752,7 +752,7 @@ void main() { await tester.pumpWidget( Center( child: RepaintBoundary( - child: Container( + child: ColoredBox( color: Colors.white, child: Padding( padding: const EdgeInsets.all(100.0), @@ -768,7 +768,7 @@ void main() { ), ), color: Colors.red, - child: Container( + child: ColoredBox( color: Colors.white, child: RepaintBoundary( child: Center( diff --git a/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart index e93fb5c5a785..63e067119ad0 100644 --- a/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart +++ b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart @@ -45,7 +45,7 @@ void main() { builder: (BuildContext context, ScrollController scrollController) { return NotificationListener( onNotification: onScrollNotification, - child: Container( + child: ColoredBox( key: containerKey, color: const Color(0xFFABCDEF), child: ListView.builder( 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 8cb09df2e2bf..1584103a837e 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 @@ -242,7 +242,7 @@ void main() { Container( color: Colors.red, ), - Container( + ColoredBox( color: Colors.green, child: TextField( controller: textController, diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index 00f86f8e4370..f8b141acb455 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -14578,7 +14578,7 @@ class _CustomTextSelectionToolbar extends StatelessWidget { anchorAbove: anchorAbove, anchorBelow: anchorBelow, toolbarBuilder: (BuildContext context, Widget child) { - return Container( + return ColoredBox( color: Colors.pink, child: child, ); diff --git a/packages/flutter/test/widgets/flex_test.dart b/packages/flutter/test/widgets/flex_test.dart index a8cf476cb825..0e112b71549f 100644 --- a/packages/flutter/test/widgets/flex_test.dart +++ b/packages/flutter/test/widgets/flex_test.dart @@ -12,7 +12,7 @@ void main() { await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, - child: Container( + child: ColoredBox( color: const Color(0xFF00FF00), child: Stack( children: [ diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index 6d698d3ef8d3..80c6088d4bbd 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -901,7 +901,7 @@ void main() { children: [ const SwapKeyWidget(childKey: ValueKey(0)), Container(key: const ValueKey(1)), - Container(color: Colors.green, child: SizedBox(key: key)), + ColoredBox(color: Colors.green, child: SizedBox(key: key)), ], ); await tester.pumpWidget(stack); @@ -1234,7 +1234,7 @@ void main() { children: [ Container(), Container(key: GlobalKey()), - Container(color: Colors.green, child: Container()), + ColoredBox(color: Colors.green, child: Container()), Container(key: GlobalKey()), Container(), ], @@ -1252,11 +1252,10 @@ void main() { '├Container-[GlobalKey#00000]\n' '│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n' '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n' - '├Container(bg: MaterialColor(primary value: Color(0xff4caf50)))\n' - '│└ColoredBox(color: MaterialColor(primary value: Color(0xff4caf50)), renderObject: _RenderColoredBox#00000 relayoutBoundary=up1)\n' - '│ └Container\n' - '│ └LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up2)\n' - '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up3)\n' + '├ColoredBox(color: MaterialColor(primary value: Color(0xff4caf50)), renderObject: _RenderColoredBox#00000 relayoutBoundary=up1)\n' + '│└Container\n' + '│ └LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up2)\n' + '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up3)\n' '├Container-[GlobalKey#00000]\n' '│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n' '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n' diff --git a/packages/flutter/test/widgets/grid_view_test.dart b/packages/flutter/test/widgets/grid_view_test.dart index d6c693e92c7d..1a4f29cedaf3 100644 --- a/packages/flutter/test/widgets/grid_view_test.dart +++ b/packages/flutter/test/widgets/grid_view_test.dart @@ -78,7 +78,7 @@ void main() { onTap: () { log.add(state); }, - child: Container( + child: ColoredBox( color: const Color(0xFF0000FF), child: Text(state), ), @@ -151,7 +151,7 @@ void main() { onTap: () { log.add(state); }, - child: Container( + child: ColoredBox( color: const Color(0xFF0000FF), child: Text(state), ), diff --git a/packages/flutter/test/widgets/list_view_test.dart b/packages/flutter/test/widgets/list_view_test.dart index 64c571060382..156b569e8bdf 100644 --- a/packages/flutter/test/widgets/list_view_test.dart +++ b/packages/flutter/test/widgets/list_view_test.dart @@ -167,7 +167,7 @@ void main() { child: ListView( itemExtent: 200.0, children: List.generate(20, (int i) { - return Container( + return ColoredBox( color: Colors.green, child: Text('$i'), ); @@ -176,7 +176,7 @@ void main() { ), ); - final RenderBox box = tester.renderObject(find.byType(Container).first); + final RenderBox box = tester.renderObject(find.byType(ColoredBox).first); expect(box.size.height, equals(200.0)); expect(find.text('0'), findsOneWidget); diff --git a/packages/flutter/test/widgets/lookup_boundary_test.dart b/packages/flutter/test/widgets/lookup_boundary_test.dart index 9b75cc98540c..36d2d3b310b7 100644 --- a/packages/flutter/test/widgets/lookup_boundary_test.dart +++ b/packages/flutter/test/widgets/lookup_boundary_test.dart @@ -446,6 +446,7 @@ void main() { key: outerContainerKey, child: LookupBoundary( child: Container( + padding: const EdgeInsets.all(10), color: Colors.blue, child: Container( key: innerContainerKey, @@ -963,6 +964,7 @@ void main() { testWidgets('is hiding', (WidgetTester tester) async { bool? isHidden; await tester.pumpWidget(Container( + padding: const EdgeInsets.all(10), color: Colors.blue, child: LookupBoundary( child: Builder( @@ -979,9 +981,11 @@ void main() { testWidgets('is not hiding entity within boundary', (WidgetTester tester) async { bool? isHidden; await tester.pumpWidget(Container( + padding: const EdgeInsets.all(10), color: Colors.blue, child: LookupBoundary( child: Container( + padding: const EdgeInsets.all(10), color: Colors.red, child: Builder( builder: (BuildContext context) { @@ -998,6 +1002,7 @@ void main() { testWidgets('is not hiding if no boundary exists', (WidgetTester tester) async { bool? isHidden; await tester.pumpWidget(Container( + padding: const EdgeInsets.all(10), color: Colors.blue, child: Builder( builder: (BuildContext context) { diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index d581037aba02..2bfb82a0eddc 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -18,9 +18,9 @@ class FirstWidget extends StatelessWidget { onTap: () { Navigator.pushNamed(context, '/second'); }, - child: Container( - color: const Color(0xFFFFFF00), - child: const Text('X'), + child: const ColoredBox( + color: Color(0xFFFFFF00), + child: Text('X'), ), ); } @@ -37,9 +37,9 @@ class SecondWidgetState extends State { Widget build(BuildContext context) { return GestureDetector( onTap: () => Navigator.pop(context), - child: Container( - color: const Color(0xFFFF00FF), - child: const Text('Y'), + child: const ColoredBox( + color: Color(0xFFFF00FF), + child: Text('Y'), ), ); } diff --git a/packages/flutter/test/widgets/opacity_repaint_test.dart b/packages/flutter/test/widgets/opacity_repaint_test.dart index c285075c5a57..b0aff87cd675 100644 --- a/packages/flutter/test/widgets/opacity_repaint_test.dart +++ b/packages/flutter/test/widgets/opacity_repaint_test.dart @@ -10,9 +10,9 @@ void main() { testWidgets('RenderOpacity avoids repainting and does not drop layer at fully opaque', (WidgetTester tester) async { RenderTestObject.paintCount = 0; await tester.pumpWidget( - Container( + const ColoredBox( color: Colors.red, - child: const Opacity( + child: Opacity( opacity: 0.0, child: TestWidget(), ), @@ -22,9 +22,9 @@ void main() { expect(RenderTestObject.paintCount, 0); await tester.pumpWidget( - Container( + const ColoredBox( color: Colors.red, - child: const Opacity( + child: Opacity( opacity: 0.1, child: TestWidget(), ), @@ -34,9 +34,9 @@ void main() { expect(RenderTestObject.paintCount, 1); await tester.pumpWidget( - Container( + const ColoredBox( color: Colors.red, - child: const Opacity( + child: Opacity( opacity: 1, child: TestWidget(), ), @@ -50,9 +50,9 @@ void main() { RenderTestObject.paintCount = 0; await tester.pumpWidget( - Container( + const ColoredBox( color: Colors.red, - child: const Opacity( + child: Opacity( opacity: 0.5, child: TestWidget(), ), @@ -62,9 +62,9 @@ void main() { expect(RenderTestObject.paintCount, 1); await tester.pumpWidget( - Container( + const ColoredBox( color: Colors.red, - child: const Opacity( + child: Opacity( opacity: 0.0, child: TestWidget(), ), diff --git a/packages/flutter/test/widgets/page_transitions_test.dart b/packages/flutter/test/widgets/page_transitions_test.dart index a0d82517d32d..55729ea2395a 100644 --- a/packages/flutter/test/widgets/page_transitions_test.dart +++ b/packages/flutter/test/widgets/page_transitions_test.dart @@ -136,9 +136,9 @@ void main() { final Map routes = { '/': (_) => Scaffold( key: containerKey1, - body: Container( - color: const Color(0xff00ffff), - child: const Hero( + body: const ColoredBox( + color: Color(0xff00ffff), + child: Hero( tag: kHeroTag, child: Text('Home'), ), diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 3d346f04ac12..a14505a877b8 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -59,11 +59,11 @@ void main() { Stack( textDirection: TextDirection.ltr, children: [ - Container( + ColoredBox( color: Colors.green, child: StateMarker(key: left), ), - Container( + ColoredBox( color: Colors.green, child: StateMarker( key: right, @@ -88,14 +88,14 @@ void main() { Stack( textDirection: TextDirection.ltr, children: [ - Container( + ColoredBox( color: Colors.green, child: StateMarker( key: right, child: newGrandchild, ), ), - Container( + ColoredBox( color: Colors.green, child: StateMarker(key: left), ), @@ -115,7 +115,7 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: ColoredBox( color: Colors.green, child: StateMarker( key: left, @@ -183,7 +183,7 @@ void main() { await tester.pumpWidget( Center( - child: Container( + child: ColoredBox( color: Colors.green, child: StateMarker( key: left, diff --git a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart index 061db34dad16..e27a3851ffe2 100644 --- a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart @@ -108,17 +108,17 @@ void main() { }, ); }), - Container( + ColoredBox( color: Colors.green, - child: Container( + child: ColoredBox( color: Colors.green, - child: Container( + child: ColoredBox( color: Colors.green, - child: Container( + child: ColoredBox( color: Colors.green, - child: Container( + child: ColoredBox( color: Colors.green, - child: Container( + child: ColoredBox( color: Colors.green, child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { diff --git a/packages/flutter/test/widgets/rich_text_test.dart b/packages/flutter/test/widgets/rich_text_test.dart index 5cae15358ce5..79dc0c537e69 100644 --- a/packages/flutter/test/widgets/rich_text_test.dart +++ b/packages/flutter/test/widgets/rich_text_test.dart @@ -143,7 +143,7 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: Center( - child: Container( + child: ColoredBox( color: Colors.green, child: IntrinsicHeight( child: RichText( diff --git a/packages/flutter/test/widgets/scrollable_fling_test.dart b/packages/flutter/test/widgets/scrollable_fling_test.dart index 3692f456f66f..095df2a13506 100644 --- a/packages/flutter/test/widgets/scrollable_fling_test.dart +++ b/packages/flutter/test/widgets/scrollable_fling_test.dart @@ -17,7 +17,7 @@ Future pumpTest(WidgetTester tester, TargetPlatform platform) async { theme: ThemeData( platform: platform, ), - home: Container( + home: ColoredBox( color: const Color(0xFF111111), child: ListView.builder( dragStartBehavior: DragStartBehavior.down, diff --git a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart index 76c50d41bf82..79f0b506334c 100644 --- a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart +++ b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart @@ -184,7 +184,7 @@ void main() { sliverBox, SliverFillRemaining( hasScrollBody: false, - child: Container( + child: ColoredBox( key: key, color: Colors.blue, child: Align( @@ -387,7 +387,7 @@ void main() { SliverFillRemaining( hasScrollBody: false, fillOverscroll: true, - child: Container( + child: ColoredBox( key: key, color: Colors.blue, child: Align( @@ -673,7 +673,7 @@ void main() { SliverFillRemaining( hasScrollBody: false, fillOverscroll: true, - child: Container( + child: ColoredBox( key: key, color: Colors.blue, child: Align( diff --git a/packages/flutter/test/widgets/sliver_fill_viewport_test.dart b/packages/flutter/test/widgets/sliver_fill_viewport_test.dart index f636dc535afc..a08d235a979e 100644 --- a/packages/flutter/test/widgets/sliver_fill_viewport_test.dart +++ b/packages/flutter/test/widgets/sliver_fill_viewport_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('SliverFillViewport control test', (WidgetTester tester) async { final List children = List.generate(20, (int i) { - return Container(color: Colors.green, child: Text('$i', textDirection: TextDirection.ltr)); + return ColoredBox(color: Colors.green, child: Text('$i', textDirection: TextDirection.ltr)); }); await tester.pumpWidget( @@ -25,7 +25,7 @@ void main() { ), ); - final RenderBox box = tester.renderObject(find.byType(Container).first); + final RenderBox box = tester.renderObject(find.byType(ColoredBox).first); expect(box.size.height, equals(600.0)); expect(find.text('0'), findsOneWidget); @@ -52,7 +52,7 @@ void main() { await tester.drag(find.byType(Scrollable), const Offset(0.0, 700.0)); await tester.pump(); - final RenderBox box2 = tester.renderObject(find.byType(Container).first); + final RenderBox box2 = tester.renderObject(find.byType(ColoredBox).first); expect(box2.size.height, equals(600.0)); expect(find.text('0'), findsOneWidget); diff --git a/packages/flutter/test/widgets/slivers_evil_test.dart b/packages/flutter/test/widgets/slivers_evil_test.dart index a7abfb99a6aa..cf88354494a3 100644 --- a/packages/flutter/test/widgets/slivers_evil_test.dart +++ b/packages/flutter/test/widgets/slivers_evil_test.dart @@ -193,7 +193,7 @@ void main() { itemExtent: 100.0, delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - return Container( + return ColoredBox( color: Colors.blue, child: Text(index.toString()), ); @@ -209,8 +209,8 @@ void main() { await tester.pump(); // Screen is 600px high. Moved bottom item 500px up. It's now at the top. - expect(tester.getTopLeft(find.widgetWithText(Container, '5')).dy, 0.0); - expect(tester.getBottomLeft(find.widgetWithText(Container, '10')).dy, 600.0); + expect(tester.getTopLeft(find.widgetWithText(ColoredBox, '5')).dy, 0.0); + expect(tester.getBottomLeft(find.widgetWithText(ColoredBox, '10')).dy, 600.0); // Stop returning the first 3 items. await tester.pumpWidget(MaterialApp( @@ -222,7 +222,7 @@ void main() { delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { if (index > 3) { - return Container( + return ColoredBox( color: Colors.blue, child: Text(index.toString()), ); @@ -242,10 +242,10 @@ void main() { // Move up by 4 items, meaning item 1 would have been at the top but // 0 through 3 no longer exist, so item 4, 3 items down, is the first one. // Item 4 is also shifted to the top. - expect(tester.getTopLeft(find.widgetWithText(Container, '4')).dy, 0.0); + expect(tester.getTopLeft(find.widgetWithText(ColoredBox, '4')).dy, 0.0); // Because the screen is still 600px, item 9 is now visible at the bottom instead // of what's supposed to be item 6 had we not re-shifted. - expect(tester.getBottomLeft(find.widgetWithText(Container, '9')).dy, 600.0); + expect(tester.getBottomLeft(find.widgetWithText(ColoredBox, '9')).dy, 600.0); }); } diff --git a/packages/flutter/test/widgets/syncing_test.dart b/packages/flutter/test/widgets/syncing_test.dart index 39d37c9e7998..5c7f0fcd4b4c 100644 --- a/packages/flutter/test/widgets/syncing_test.dart +++ b/packages/flutter/test/widgets/syncing_test.dart @@ -50,9 +50,9 @@ void main() { testWidgets('no change', (WidgetTester tester) async { await tester.pumpWidget( - Container( + ColoredBox( color: Colors.blue, - child: Container( + child: ColoredBox( color: Colors.blue, child: TestWidget( persistentState: 1, @@ -69,9 +69,9 @@ void main() { expect(state.updates, equals(0)); await tester.pumpWidget( - Container( + ColoredBox( color: Colors.blue, - child: Container( + child: ColoredBox( color: Colors.blue, child: TestWidget( persistentState: 2, @@ -90,9 +90,9 @@ void main() { testWidgets('remove one', (WidgetTester tester) async { await tester.pumpWidget( - Container( + ColoredBox( color: Colors.blue, - child: Container( + child: ColoredBox( color: Colors.blue, child: TestWidget( persistentState: 10, @@ -109,7 +109,7 @@ void main() { expect(state.updates, equals(0)); await tester.pumpWidget( - Container( + ColoredBox( color: Colors.green, child: TestWidget( persistentState: 11, diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index e213f71a1bd9..c3d5499337d5 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -536,7 +536,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { await tester.pumpWidget( RepaintBoundary( key: repaintBoundaryKey, - child: Container( + child: ColoredBox( color: Colors.grey, child: Transform( transform: mainTransform, @@ -544,7 +544,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { textDirection: TextDirection.ltr, child: WidgetInspector( selectButtonBuilder: null, - child: Container( + child: ColoredBox( color: Colors.white, child: Center( child: Container( @@ -3862,7 +3862,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { await tester.pumpWidget( Center( child: RepaintBoundaryWithDebugPaint( - child: Container( + child: ColoredBox( key: outerContainerKey, color: Colors.white, child: Padding( @@ -3881,10 +3881,10 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { bottomLeft: Radius.elliptical(2.5, 12.0), bottomRight: Radius.elliptical(15.0, 6.0), ), - child: Container( + child: ColoredBox( key: redContainerKey, color: Colors.red, - child: Container( + child: ColoredBox( key: whiteContainerKey, color: Colors.white, child: RepaintBoundary( @@ -4166,14 +4166,14 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { textDirection: TextDirection.ltr, child: Center( child: Row( - children: [ + children: const [ Flexible( - child: Container( + child: ColoredBox( color: Colors.green, - child: const Text('a'), + child: Text('a'), ), ), - const Text('b'), + Text('b'), ], ), ), diff --git a/packages/flutter/test/widgets/wrap_test.dart b/packages/flutter/test/widgets/wrap_test.dart index 1d32f6cf4645..171b34759f25 100644 --- a/packages/flutter/test/widgets/wrap_test.dart +++ b/packages/flutter/test/widgets/wrap_test.dart @@ -897,7 +897,7 @@ void main() { textDirection: TextDirection.ltr, child: Center( child: IntrinsicHeight( - child: Container( + child: ColoredBox( color: Colors.green, child: Wrap( children: [ @@ -929,7 +929,7 @@ void main() { textDirection: TextDirection.ltr, child: Center( child: IntrinsicWidth( - child: Container( + child: ColoredBox( color: Colors.green, child: Wrap( direction: Axis.vertical,