Enable use_colored_box lint (#117370)

This commit is contained in:
Michael Goderbauer 2022-12-20 14:09:55 -08:00 committed by GitHub
parent 46bb85376b
commit 81bc54be75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 198 additions and 194 deletions

View File

@ -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

View File

@ -524,7 +524,7 @@ class ItemGalleryBox extends StatelessWidget {
child: Column(
children: <Widget>[
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)),

View File

@ -91,7 +91,7 @@ class _BackdropFilterPageState extends State<BackdropFilterPage> with TickerProv
child: addBlur(grid(txt, 17, 5), _blurGroup),
),
const SizedBox(height: 20),
Container(
ColoredBox(
color: Colors.white,
child:Row(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -74,9 +74,9 @@ class _PostBackdropFilterPageState extends State<PostBackdropFilterPage> with Ti
),
getConditionalBackdrop(),
RepaintBoundary(
child: Container(
child: ColoredBox(
color: Colors.white,
child:Row(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('Include BackdropFilter:'),

View File

@ -88,7 +88,7 @@ class WindowManagerBodyState extends State<WindowManagerBody> {
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!,

View File

@ -520,7 +520,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
final List<Widget> headings = <Widget>[];
for (int index = 0; index < allSections.length; index++) {
headings.add(Container(
headings.add(ColoredBox(
color: _kAppBackgroundColor,
child: ClipRect(
child: _AllSectionsView(

View File

@ -214,7 +214,7 @@ class Tab1RowItem extends StatelessWidget {
),
));
},
child: Container(
child: ColoredBox(
color: CupertinoDynamicColor.resolve(CupertinoColors.systemBackground, context),
child: SafeArea(
top: false,

View File

@ -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: <Widget>[

View File

@ -358,7 +358,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
);
}).toList();
return Container(
return ColoredBox(
key: _backdropKey,
color: theme.primaryColor,
child: Stack(

View File

@ -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(

View File

@ -122,7 +122,7 @@ class NestedViewEventBodyState extends State<NestedViewEventBody> {
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,

View File

@ -66,7 +66,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
body: Column(
children: <Widget>[
Container(color: Colors.grey.shade200, child: Options(_model)),
ColoredBox(color: Colors.grey.shade200, child: Options(_model)),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,

View File

@ -508,7 +508,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.black,
child: Column(
children: <Widget>[
@ -577,7 +577,7 @@ class _UnderlinesState extends State<Underlines> {
@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<Fallback> {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Container(
return ColoredBox(
color: Colors.black,
child: Column(
children: <Widget>[
@ -754,7 +754,7 @@ class Bidi extends StatefulWidget {
class _BidiState extends State<Bidi> {
@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<Zalgo> with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.black,
child: Column(
children: <Widget>[
@ -988,7 +988,7 @@ class _PaintingState extends State<Painting> 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,

View File

@ -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),
),
),
),

View File

@ -30,10 +30,10 @@ class DividerExample extends StatelessWidget {
return Center(
child: Column(
children: <Widget>[
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'),

View File

@ -42,7 +42,7 @@ class _ReorderableExampleState extends State<ReorderableExample> {
buildDefaultDragHandles: false,
children: <Widget>[
for (int index = 0; index < _items.length; index++)
Container(
ColoredBox(
key: Key('$index'),
color: _items[index].isOdd ? oddItemColor : evenItemColor,
child: Row(

View File

@ -66,7 +66,7 @@ class _StarBorderExampleState extends State<StarBorderExample> {
),
child: ListView(
children: <Widget>[
Container(
ColoredBox(
color: Colors.grey.shade200,
child: Options(_model),
),

View File

@ -49,7 +49,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => _updateSize(),
child: Container(
child: ColoredBox(
color: Colors.amberAccent,
child: AnimatedSize(
curve: Curves.easeIn,

View File

@ -34,7 +34,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -69,7 +69,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
onPointerDown: _incrementDown,
onPointerMove: _updateLocation,
onPointerUp: _incrementUp,
child: Container(
child: ColoredBox(
color: Colors.lightBlueAccent,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -67,7 +67,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
onEnter: _incrementEnter,
onHover: _updateLocation,
onExit: _incrementExit,
child: Container(
child: ColoredBox(
color: Colors.lightBlueAccent,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -36,7 +36,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@override
Widget build(BuildContext context) {
return Material(
child: Container(
child: ColoredBox(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -125,7 +125,7 @@ class MyStatelessWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.white,
child: FocusTraversalGroup(
policy: OrderedTraversalPolicy(),

View File

@ -47,7 +47,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
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<MyStatefulWidget> {
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),
),
),
),

View File

@ -56,9 +56,9 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
selected = !selected;
});
},
child: Container(
child: const ColoredBox(
color: Colors.blue,
child: const Center(child: Text('Tap me')),
child: Center(child: Text('Tap me')),
),
),
),

View File

@ -57,7 +57,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget>
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.white,
child: AlignTransition(
alignment: _animation,

View File

@ -70,7 +70,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget>
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.white,
child: Center(
child: DecoratedBoxTransition(

View File

@ -50,7 +50,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget>
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.white,
child: FadeTransition(
opacity: _animation,

View File

@ -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'));

View File

@ -81,9 +81,9 @@ abstract class Animation<T> extends Listenable implements ValueListenable<T> {
/// 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<T> extends Listenable implements ValueListenable<T> {
/// opacity: Animation<double>.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'),
/// ),
/// );
/// }

View File

@ -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,

View File

@ -50,7 +50,7 @@ import 'theme_data.dart';
///
/// {@tool snippet}
/// ```dart
/// Container(
/// ColoredBox(
/// color: Colors.green,
/// child: Material(
/// child: CheckboxListTile(

View File

@ -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,

View File

@ -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<T extends StatefulWidget> on State<T> {
/// class MyWidgetState extends State<MyWidget> with MaterialStateMixin<MyWidget> {
/// @override
/// Widget build(BuildContext context) {
/// return Container(
/// return ColoredBox(
/// color: isPressed ? Colors.black : Colors.white,
/// child: InkWell(
/// onHighlightChanged: updateMaterialState(

View File

@ -574,7 +574,7 @@ class _PopupMenu<T> 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,
);

View File

@ -53,7 +53,7 @@ import 'theme_data.dart';
///
/// {@tool snippet}
/// ```dart
/// Container(
/// ColoredBox(
/// color: Colors.green,
/// child: Material(
/// child: RadioListTile<Meridiem>(

View File

@ -57,7 +57,7 @@ enum _SwitchListTileType { material, adaptive }
///
/// {@tool snippet}
/// ```dart
/// Container(
/// ColoredBox(
/// color: Colors.green,
/// child: Material(
/// child: SwitchListTile(

View File

@ -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,

View File

@ -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);
/// }
/// }
/// ```

View File

@ -68,7 +68,7 @@ import 'viewport.dart';
/// body: PageView(
/// controller: _pageController,
/// children: <Widget>[
/// 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(

View File

@ -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,

View File

@ -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(

View File

@ -208,7 +208,7 @@ Widget buildDropdownWithHint({
selectedItemBuilder: enableSelectedItemBuilder
? (BuildContext context) {
return menuItems.map<Widget>((String item) {
return Container(
return ColoredBox(
color: const Color(0xff00ff00),
child: Text(item),
);

View File

@ -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(),
),
),
),
),
);

View File

@ -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<void> verify(WidgetTester tester, Widget widget, StreamController<bool> 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<Container>(find.byKey(key)).color, trueColor);
expect(tester.widget<ColoredBox>(find.byKey(key)).color, trueColor);
// Set the value to False
controller.sink.add(false);
await tester.pumpAndSettle();
expect(tester.widget<Container>(find.byKey(key)).color, falseColor);
expect(tester.widget<ColoredBox>(find.byKey(key)).color, falseColor);
}
testWidgets('MaterialState.pressed is tracked', (WidgetTester tester) async {

View File

@ -78,7 +78,7 @@ class _NestedTabBarContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.blue,
child: Column(
children: <Widget>[

View File

@ -11639,7 +11639,7 @@ void main() {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: Container(
body: ColoredBox(
color: Colors.grey,
child: Center(
child: Container(

View File

@ -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: <Widget>[

View File

@ -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),

View File

@ -12,7 +12,7 @@ void main() {
final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1));
final Tween<double> opacityTween = Tween<double>(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<double> opacityTween = Tween<double>(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<double> opacityTween = Tween<double>(begin: 0.99, end: 0);
await tester.pumpWidget(
Container(
ColoredBox(
color: Colors.red,
child: FadeTransition(
opacity: controller.drive(opacityTween),

View File

@ -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(

View File

@ -45,7 +45,7 @@ void main() {
builder: (BuildContext context, ScrollController scrollController) {
return NotificationListener<ScrollNotification>(
onNotification: onScrollNotification,
child: Container(
child: ColoredBox(
key: containerKey,
color: const Color(0xFFABCDEF),
child: ListView.builder(

View File

@ -242,7 +242,7 @@ void main() {
Container(
color: Colors.red,
),
Container(
ColoredBox(
color: Colors.green,
child: TextField(
controller: textController,

View File

@ -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,
);

View File

@ -12,7 +12,7 @@ void main() {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Container(
child: ColoredBox(
color: const Color(0xFF00FF00),
child: Stack(
children: <Widget>[

View File

@ -901,7 +901,7 @@ void main() {
children: <Widget>[
const SwapKeyWidget(childKey: ValueKey<int>(0)),
Container(key: const ValueKey<int>(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: <Widget>[
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'

View File

@ -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),
),

View File

@ -167,7 +167,7 @@ void main() {
child: ListView(
itemExtent: 200.0,
children: List<Widget>.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<RenderBox>(find.byType(Container).first);
final RenderBox box = tester.renderObject<RenderBox>(find.byType(ColoredBox).first);
expect(box.size.height, equals(200.0));
expect(find.text('0'), findsOneWidget);

View File

@ -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) {

View File

@ -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<SecondWidget> {
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'),
),
);
}

View File

@ -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(),
),

View File

@ -136,9 +136,9 @@ void main() {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (_) => 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'),
),

View File

@ -59,11 +59,11 @@ void main() {
Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
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: <Widget>[
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,

View File

@ -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) {

View File

@ -143,7 +143,7 @@ void main() {
Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Container(
child: ColoredBox(
color: Colors.green,
child: IntrinsicHeight(
child: RichText(

View File

@ -17,7 +17,7 @@ Future<void> pumpTest(WidgetTester tester, TargetPlatform platform) async {
theme: ThemeData(
platform: platform,
),
home: Container(
home: ColoredBox(
color: const Color(0xFF111111),
child: ListView.builder(
dragStartBehavior: DragStartBehavior.down,

View File

@ -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(

View File

@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('SliverFillViewport control test', (WidgetTester tester) async {
final List<Widget> children = List<Widget>.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<RenderBox>(find.byType(Container).first);
final RenderBox box = tester.renderObject<RenderBox>(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<RenderBox>(find.byType(Container).first);
final RenderBox box2 = tester.renderObject<RenderBox>(find.byType(ColoredBox).first);
expect(box2.size.height, equals(600.0));
expect(find.text('0'), findsOneWidget);

View File

@ -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);
});
}

View File

@ -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,

View File

@ -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: <Widget>[
children: const <Widget>[
Flexible(
child: Container(
child: ColoredBox(
color: Colors.green,
child: const Text('a'),
child: Text('a'),
),
),
const Text('b'),
Text('b'),
],
),
),

View File

@ -897,7 +897,7 @@ void main() {
textDirection: TextDirection.ltr,
child: Center(
child: IntrinsicHeight(
child: Container(
child: ColoredBox(
color: Colors.green,
child: Wrap(
children: <Widget>[
@ -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,