Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Enable use_colored_box lint (#117370)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer committed Dec 20, 2022
1 parent 46bb853 commit 81bc54b
Show file tree
Hide file tree
Showing 72 changed files with 198 additions and 194 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dev/benchmarks/complex_layout/lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Tab1RowItem extends StatelessWidget {
),
));
},
child: Container(
child: ColoredBox(
color: CupertinoDynamicColor.resolve(CupertinoColors.systemBackground, context),
child: SafeArea(
top: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
);
}).toList();

return Container(
return ColoredBox(
key: _backdropKey,
color: theme.primaryColor,
child: Stack(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ class _LeaveBehindListItem extends StatelessWidget {
}
return false;
},
background: Container(
background: ColoredBox(
color: theme.primaryColor,
child: const Center(
child: ListTile(
leading: Icon(Icons.delete, color: Colors.white, size: 36.0),
),
),
),
secondaryBackground: Container(
secondaryBackground: ColoredBox(
color: theme.primaryColor,
child: const Center(
child: ListTile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dev/manual_tests/lib/star_border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions dev/manual_tests/lib/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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>[
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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>[
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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>[
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
),
),
Expand Down
8 changes: 4 additions & 4 deletions examples/api/lib/material/divider/divider.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
),
Expand All @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion examples/api/lib/painting/star_border/star_border.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _StarBorderExampleState extends State<StarBorderExample> {
),
child: ListView(
children: <Widget>[
Container(
ColoredBox(
color: Colors.grey.shade200,
child: Options(_model),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/api/lib/widgets/basic/listener.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/api/lib/widgets/basic/mouse_region.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class MyStatelessWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
return ColoredBox(
color: Colors.white,
child: FocusTraversalGroup(
policy: OrderedTraversalPolicy(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ 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,
heightFactor: selected ? 0.75 : 0.25,
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),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions examples/api/test/material/divider/divider.0_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter/lib/src/animation/animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
/// ),
/// );
/// }
Expand All @@ -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'),
/// ),
/// );
/// }
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/cupertino/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class CupertinoAlertDialog extends StatelessWidget {
),
];

return Container(
return ColoredBox(
color: CupertinoDynamicColor.resolve(_kDialogColor, context),
child: Column(
mainAxisSize: MainAxisSize.min,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 81bc54b

Please sign in to comment.