From 36052e68ddb8c18dd8a9405b598e20789d5ad559 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Thu, 27 Apr 2017 14:19:01 -0700 Subject: [PATCH] BoxDecoration API changes: backgroundColor -> color et al (#9648) backgroundColor -> color backgroundImage -> image BackgroundImage -> DecorationImage --- dev/benchmarks/complex_layout/lib/main.dart | 18 +-- dev/manual_tests/drag_and_drop.dart | 4 +- .../lib/demo/animation/home.dart | 2 +- .../lib/demo/animation/widgets.dart | 8 +- .../demo/material/bottom_navigation_demo.dart | 4 +- .../lib/demo/material/drawer_demo.dart | 2 +- .../lib/demo/material/leave_behind_demo.dart | 2 +- .../lib/demo/shrine/shrine_home.dart | 4 +- examples/layers/rendering/flex_layout.dart | 8 +- .../layers/rendering/spinning_square.dart | 2 +- .../layers/rendering/src/sector_layout.dart | 10 +- .../layers/rendering/src/solid_color_box.dart | 6 +- examples/layers/services/isolate.dart | 4 +- examples/layers/widgets/media_query.dart | 8 +- examples/layers/widgets/spinning_mixed.dart | 2 +- examples/layers/widgets/spinning_square.dart | 4 +- .../flutter/lib/src/cupertino/button.dart | 2 +- .../flutter/lib/src/cupertino/dialog.dart | 2 +- packages/flutter/lib/src/material/chip.dart | 2 +- .../lib/src/material/circle_avatar.dart | 4 +- .../flutter/lib/src/material/data_table.dart | 2 +- .../flutter/lib/src/material/date_picker.dart | 2 +- packages/flutter/lib/src/material/drawer.dart | 7 +- .../flutter/lib/src/material/dropdown.dart | 4 +- .../lib/src/material/grid_tile_bar.dart | 2 +- .../flutter/lib/src/material/material.dart | 2 +- .../lib/src/material/mergeable_material.dart | 4 +- .../src/material/paginated_data_table.dart | 4 +- .../flutter/lib/src/material/stepper.dart | 14 +- packages/flutter/lib/src/material/switch.dart | 4 +- packages/flutter/lib/src/material/tabs.dart | 4 +- .../flutter/lib/src/material/tooltip.dart | 2 +- .../lib/src/material/two_level_list.dart | 2 +- .../material/user_accounts_drawer_header.dart | 2 +- .../flutter/lib/src/painting/box_painter.dart | 86 +++++----- .../flutter/lib/src/widgets/container.dart | 14 +- .../lib/src/widgets/implicit_animations.dart | 148 ++++++++++-------- .../lib/src/widgets/modal_barrier.dart | 2 +- .../test/material/circle_avatar_test.dart | 6 +- .../flutter/test/material/dialog_test.dart | 4 +- .../test/material/grid_title_test.dart | 2 +- .../flutter/test/material/material_test.dart | 4 +- .../flutter/test/material/scaffold_test.dart | 4 +- .../flutter/test/material/tooltip_test.dart | 8 +- .../test/painting/decoration_test.dart | 34 ++-- packages/flutter/test/rendering/box_test.dart | 6 +- .../flutter/test/rendering/stack_test.dart | 6 +- .../test/widgets/animated_container_test.dart | 30 ++-- .../test/widgets/box_decoration_test.dart | 2 +- .../flutter/test/widgets/container_test.dart | 8 +- .../flutter/test/widgets/draggable_test.dart | 16 +- .../flutter/test/widgets/drawer_test.dart | 4 +- .../test/widgets/ensure_visible_test.dart | 8 +- packages/flutter/test/widgets/flex_test.dart | 7 +- packages/flutter/test/widgets/flow_test.dart | 4 +- .../test/widgets/gesture_detector_test.dart | 16 +- .../flutter/test/widgets/grid_view_test.dart | 10 +- .../widgets/implicit_animations_test.dart | 6 +- .../test/widgets/list_view_misc_test.dart | 12 +- .../widgets/list_view_viewporting_test.dart | 12 +- .../flutter/test/widgets/navigator_test.dart | 16 +- .../widgets/overscroll_indicator_test.dart | 4 +- .../test/widgets/page_transitions_test.dart | 4 +- .../flutter/test/widgets/page_view_test.dart | 8 +- .../widgets/render_object_widget_test.dart | 8 +- .../test/widgets/scroll_view_test.dart | 12 +- .../single_child_scroll_view_test.dart | 24 +-- packages/flutter/test/widgets/stack_test.dart | 2 +- .../state_setting_in_scrollables_test.dart | 12 +- .../flutter/test/widgets/test_widgets.dart | 6 +- .../flutter/test/widgets/transform_test.dart | 28 +--- .../test/widgets/transitions_test.dart | 14 +- .../flutter_markdown/lib/src/style_sheet.dart | 8 +- 73 files changed, 328 insertions(+), 430 deletions(-) diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index ec8e370b9c..0eb3ae4f02 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -315,7 +315,7 @@ class MiniIconWithText extends StatelessWidget { width: 16.0, height: 16.0, decoration: new BoxDecoration( - backgroundColor: Theme.of(context).primaryColor, + color: Theme.of(context).primaryColor, shape: BoxShape.circle ), child: new Icon(icon, color: Colors.white, size: 12.0) @@ -332,9 +332,7 @@ class FatDivider extends StatelessWidget { Widget build(BuildContext context) { return new Container( height: 8.0, - decoration: new BoxDecoration( - backgroundColor: Theme.of(context).dividerColor - ) + color: Theme.of(context).dividerColor, ); } } @@ -436,7 +434,7 @@ class ItemImageBox extends StatelessWidget { left: 4.0, child: new Container( decoration: new BoxDecoration( - backgroundColor: Colors.black54, + color: Colors.black54, borderRadius: new BorderRadius.circular(2.0) ), padding: const EdgeInsets.all(4.0), @@ -506,9 +504,7 @@ class ItemGalleryBox extends StatelessWidget { children: [ new Expanded( child: new Container( - decoration: new BoxDecoration( - backgroundColor: Theme.of(context).primaryColor, - ), + color: Theme.of(context).primaryColor, child: new Center( child: new Text(tabName, style: Theme.of(context).textTheme.headline.copyWith(color: Colors.white)), ) @@ -665,10 +661,8 @@ class FancyDrawerHeader extends StatelessWidget { @override Widget build(BuildContext context) { return new Container( - decoration: const BoxDecoration( - backgroundColor: Colors.purple - ), - height: 200.0 + color: Colors.purple, + height: 200.0, ); } } diff --git a/dev/manual_tests/drag_and_drop.dart b/dev/manual_tests/drag_and_drop.dart index ebc16b30cf..71a0b73d3a 100644 --- a/dev/manual_tests/drag_and_drop.dart +++ b/dev/manual_tests/drag_and_drop.dart @@ -29,11 +29,11 @@ class ExampleDragTargetState extends State { height: 100.0, margin: const EdgeInsets.all(10.0), decoration: new BoxDecoration( + color: data.isEmpty ? _color : Colors.grey.shade200, border: new Border.all( width: 3.0, color: data.isEmpty ? Colors.white : Colors.blue ), - backgroundColor: data.isEmpty ? _color : Colors.grey.shade200 ) ); } @@ -63,7 +63,7 @@ class DotState extends State { width: widget.size, height: widget.size, decoration: new BoxDecoration( - backgroundColor: widget.color, + color: widget.color, border: new Border.all(width: taps.toDouble()), shape: BoxShape.circle ), diff --git a/examples/flutter_gallery/lib/demo/animation/home.dart b/examples/flutter_gallery/lib/demo/animation/home.dart index 91e4e83b1c..e669e0f3fd 100644 --- a/examples/flutter_gallery/lib/demo/animation/home.dart +++ b/examples/flutter_gallery/lib/demo/animation/home.dart @@ -446,7 +446,7 @@ class _AnimationDemoHomeState extends State { final List headings = []; for (int index = 0; index < allSections.length; index++) { headings.add(new Container( - decoration: const BoxDecoration(backgroundColor: _kAppBackgroundColor), + color: _kAppBackgroundColor, child: new ClipRect( child: new _AllSectionsView( sectionIndex: index, diff --git a/examples/flutter_gallery/lib/demo/animation/widgets.dart b/examples/flutter_gallery/lib/demo/animation/widgets.dart index 892d88a1b1..bc0d8c6222 100644 --- a/examples/flutter_gallery/lib/demo/animation/widgets.dart +++ b/examples/flutter_gallery/lib/demo/animation/widgets.dart @@ -110,9 +110,7 @@ class SectionIndicator extends StatelessWidget { child: new Container( width: kSectionIndicatorWidth, height: 3.0, - decoration: new BoxDecoration( - backgroundColor: Colors.white.withOpacity(opacity), - ), + color: Colors.white.withOpacity(opacity), ), ); } @@ -132,7 +130,7 @@ class SectionDetailView extends StatelessWidget { final Widget image = new DecoratedBox( decoration: new BoxDecoration( borderRadius: new BorderRadius.circular(6.0), - backgroundImage: new BackgroundImage( + image: new DecorationImage( image: new AssetImage(detail.imageAsset), fit: BoxFit.cover, alignment: FractionalOffset.center, @@ -156,7 +154,7 @@ class SectionDetailView extends StatelessWidget { } return new DecoratedBox( - decoration: new BoxDecoration(backgroundColor: Colors.grey.shade200), + decoration: new BoxDecoration(color: Colors.grey.shade200), child: item, ); } diff --git a/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart b/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart index e63f3a6905..68c59a5dd6 100644 --- a/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart @@ -71,9 +71,7 @@ class CustomIcon extends StatelessWidget { margin: const EdgeInsets.all(4.0), width: iconTheme.size - 8.0, height: iconTheme.size - 8.0, - decoration: new BoxDecoration( - backgroundColor: iconTheme.color, - ), + color: iconTheme.color, ); } } diff --git a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart index 2647c7727d..2e2e2d15d0 100644 --- a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart @@ -166,7 +166,7 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { height: 100.0, decoration: new BoxDecoration( shape: BoxShape.circle, - backgroundImage: new BackgroundImage( + image: new DecorationImage( image: new AssetImage(_kAsset0), ), ), diff --git a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart index 925ce96dcc..220d6a4a53 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -115,7 +115,7 @@ class LeaveBehindDemoState extends State { ), child: new Container( decoration: new BoxDecoration( - backgroundColor: theme.canvasColor, + color: theme.canvasColor, border: new Border(bottom: new BorderSide(color: theme.dividerColor)) ), child: new ListTile( diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart index c01593dd08..a61ee5c902 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart @@ -157,7 +157,7 @@ abstract class _PriceItem extends StatelessWidget { Widget buildItem(BuildContext context, TextStyle style, EdgeInsets padding) { BoxDecoration decoration; if (_shoppingCart[product] != null) - decoration = new BoxDecoration(backgroundColor: ShrineTheme.of(context).priceHighlightColor); + decoration = new BoxDecoration(color: ShrineTheme.of(context).priceHighlightColor); return new Container( padding: padding, @@ -258,7 +258,7 @@ class _Heading extends StatelessWidget { : (screenSize.height - kToolbarHeight) * 0.70, child: new Container( decoration: new BoxDecoration( - backgroundColor: theme.cardBackgroundColor, + color: theme.cardBackgroundColor, border: new Border(bottom: new BorderSide(color: theme.dividerColor)), ), child: new CustomMultiChildLayout( diff --git a/examples/layers/rendering/flex_layout.dart b/examples/layers/rendering/flex_layout.dart index 7175341869..dc38d85712 100644 --- a/examples/layers/rendering/flex_layout.dart +++ b/examples/layers/rendering/flex_layout.dart @@ -19,18 +19,18 @@ void main() { final RenderFlex row = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic); style = const TextStyle(fontSize: 15.0, color: const Color(0xFF000000)); row.add(new RenderDecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)), + decoration: const BoxDecoration(color: const Color(0x7FFFCCCC)), child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo')) )); style = const TextStyle(fontSize: 10.0, color: const Color(0xFF000000)); row.add(new RenderDecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)), + decoration: const BoxDecoration(color: const Color(0x7FCCFFCC)), child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo')) )); final RenderFlex subrow = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic); style = const TextStyle(fontSize: 25.0, color: const Color(0xFF000000)); subrow.add(new RenderDecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)), + decoration: const BoxDecoration(color: const Color(0x7FCCCCFF)), child: new RenderParagraph(new TextSpan(style: style, text: 'foo foo foo foo')) )); subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0))); @@ -67,7 +67,7 @@ void main() { addJustificationRow(MainAxisAlignment.spaceAround); final RenderDecoratedBox root = new RenderDecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)), + decoration: const BoxDecoration(color: const Color(0xFFFFFFFF)), child: new RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0)) ); diff --git a/examples/layers/rendering/spinning_square.dart b/examples/layers/rendering/spinning_square.dart index fcf97e6d28..a7f5623f53 100644 --- a/examples/layers/rendering/spinning_square.dart +++ b/examples/layers/rendering/spinning_square.dart @@ -20,7 +20,7 @@ class NonStopVSync implements TickerProvider { void main() { // We first create a render object that represents a green box. final RenderBox green = new RenderDecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0xFF00FF00)) + decoration: const BoxDecoration(color: const Color(0xFF00FF00)) ); // Second, we wrap that green box in a render object that forces the green box // to have a specific size. diff --git a/examples/layers/rendering/src/sector_layout.dart b/examples/layers/rendering/src/sector_layout.dart index 6904b4a6dc..c2adb00347 100644 --- a/examples/layers/rendering/src/sector_layout.dart +++ b/examples/layers/rendering/src/sector_layout.dart @@ -166,9 +166,9 @@ abstract class RenderDecoratedSector extends RenderSector { if (_decoration == null) return; - if (_decoration.backgroundColor != null) { + if (_decoration.color != null) { final Canvas canvas = context.canvas; - final Paint paint = new Paint()..color = _decoration.backgroundColor; + final Paint paint = new Paint()..color = _decoration.color; final Path path = new Path(); final double outerRadius = (parentData.radius + deltaRadius); final Rect outerBounds = new Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius); @@ -558,7 +558,7 @@ class RenderSolidColor extends RenderDecoratedSector { RenderSolidColor(this.backgroundColor, { this.desiredDeltaRadius: double.INFINITY, this.desiredDeltaTheta: kTwoPi - }) : super(new BoxDecoration(backgroundColor: backgroundColor)); + }) : super(new BoxDecoration(color: backgroundColor)); double desiredDeltaRadius; double desiredDeltaTheta; @@ -578,9 +578,9 @@ class RenderSolidColor extends RenderDecoratedSector { @override void handleEvent(PointerEvent event, HitTestEntry entry) { if (event is PointerDownEvent) { - decoration = const BoxDecoration(backgroundColor: const Color(0xFFFF0000)); + decoration = const BoxDecoration(color: const Color(0xFFFF0000)); } else if (event is PointerUpEvent) { - decoration = new BoxDecoration(backgroundColor: backgroundColor); + decoration = new BoxDecoration(color: backgroundColor); } } } diff --git a/examples/layers/rendering/src/solid_color_box.dart b/examples/layers/rendering/src/solid_color_box.dart index c4e51c7bb7..5ea81e3ba5 100644 --- a/examples/layers/rendering/src/solid_color_box.dart +++ b/examples/layers/rendering/src/solid_color_box.dart @@ -10,7 +10,7 @@ class RenderSolidColorBox extends RenderDecoratedBox { final Color backgroundColor; RenderSolidColorBox(this.backgroundColor, { this.desiredSize: Size.infinite }) - : super(decoration: new BoxDecoration(backgroundColor: backgroundColor)); + : super(decoration: new BoxDecoration(color: backgroundColor)); @override double computeMinIntrinsicWidth(double height) { @@ -40,9 +40,9 @@ class RenderSolidColorBox extends RenderDecoratedBox { @override void handleEvent(PointerEvent event, BoxHitTestEntry entry) { if (event is PointerDownEvent) { - decoration = const BoxDecoration(backgroundColor: const Color(0xFFFF0000)); + decoration = const BoxDecoration(color: const Color(0xFFFF0000)); } else if (event is PointerUpEvent) { - decoration = new BoxDecoration(backgroundColor: backgroundColor); + decoration = new BoxDecoration(color: backgroundColor); } } } diff --git a/examples/layers/services/isolate.dart b/examples/layers/services/isolate.dart index c0b316c3a6..b325d7d913 100644 --- a/examples/layers/services/isolate.dart +++ b/examples/layers/services/isolate.dart @@ -244,9 +244,7 @@ class IsolateExampleState extends State with SingleTickerProvide child: new Container( width: 120.0, height: 120.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF882222) - ) + color: const Color(0xFF882222), ) ), new Opacity( diff --git a/examples/layers/widgets/media_query.dart b/examples/layers/widgets/media_query.dart index d7aec23d46..d96017e1eb 100644 --- a/examples/layers/widgets/media_query.dart +++ b/examples/layers/widgets/media_query.dart @@ -17,9 +17,7 @@ class AdaptedListItem extends StatelessWidget { width: 32.0, height: 32.0, margin: const EdgeInsets.all(8.0), - decoration: new BoxDecoration( - backgroundColor: Colors.lightBlueAccent.shade100 - ) + color: Colors.lightBlueAccent.shade100, ), new Text(name) ] @@ -39,9 +37,7 @@ class AdaptedGridItem extends StatelessWidget { children: [ new Expanded( child: new Container( - decoration: new BoxDecoration( - backgroundColor: Colors.lightBlueAccent.shade100 - ) + color: Colors.lightBlueAccent.shade100, ) ), new Container( diff --git a/examples/layers/widgets/spinning_mixed.dart b/examples/layers/widgets/spinning_mixed.dart index 2a1c06d5f3..71ba4da553 100644 --- a/examples/layers/widgets/spinning_mixed.dart +++ b/examples/layers/widgets/spinning_mixed.dart @@ -25,7 +25,7 @@ class Rectangle extends StatelessWidget { Widget build(BuildContext context) { return new Expanded( child: new Container( - decoration: new BoxDecoration(backgroundColor: color) + color: color, ) ); } diff --git a/examples/layers/widgets/spinning_square.dart b/examples/layers/widgets/spinning_square.dart index e9a4f7b903..be59f1cd61 100644 --- a/examples/layers/widgets/spinning_square.dart +++ b/examples/layers/widgets/spinning_square.dart @@ -37,9 +37,7 @@ class _SpinningSquareState extends State with SingleTickerProvid child: new Container( width: 200.0, height: 200.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ); } diff --git a/packages/flutter/lib/src/cupertino/button.dart b/packages/flutter/lib/src/cupertino/button.dart index 24ddf1b262..0e87e16b2d 100644 --- a/packages/flutter/lib/src/cupertino/button.dart +++ b/packages/flutter/lib/src/cupertino/button.dart @@ -177,7 +177,7 @@ class _CupertinoButtonState extends State with SingleTickerProv child: new DecoratedBox( decoration: new BoxDecoration( borderRadius: const BorderRadius.all(const Radius.circular(8.0)), - backgroundColor: backgroundColor != null && !enabled + color: backgroundColor != null && !enabled ? _kDisabledBackground : backgroundColor, ), diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index f0e130ee8f..dab608b028 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -40,7 +40,7 @@ const double _kCupertinoDialogWidth = 270.0; const BoxDecoration _kCupertinoDialogDecoration = const BoxDecoration( // TODO(abarth): Rather than being opaque, this decoration should actually be // partially transparent and have a subtle background blur effect. - backgroundColor: const Color(0xFFF8F8F8), + color: const Color(0xFFF8F8F8), borderRadius: const BorderRadius.all(const Radius.circular(15.0)), ); diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 4402426186..6220f5d112 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -112,7 +112,7 @@ class Chip extends StatelessWidget { height: _kChipHeight, padding: new EdgeInsets.only(left: leftPadding, right: rightPadding), decoration: new BoxDecoration( - backgroundColor: Colors.grey.shade300, + color: Colors.grey.shade300, borderRadius: new BorderRadius.circular(16.0) ), child: new Row( diff --git a/packages/flutter/lib/src/material/circle_avatar.dart b/packages/flutter/lib/src/material/circle_avatar.dart index fdb0702970..dde4fdde7c 100644 --- a/packages/flutter/lib/src/material/circle_avatar.dart +++ b/packages/flutter/lib/src/material/circle_avatar.dart @@ -94,8 +94,8 @@ class CircleAvatar extends StatelessWidget { height: radius * 2.0, duration: kThemeChangeDuration, decoration: new BoxDecoration( - backgroundColor: backgroundColor ?? theme.primaryColor, - backgroundImage: backgroundImage != null ? new BackgroundImage( + color: backgroundColor ?? theme.primaryColor, + image: backgroundImage != null ? new DecorationImage( image: backgroundImage ) : null, shape: BoxShape.circle, diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 7f31161767..49fa399957 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -499,7 +499,7 @@ class DataTable extends StatelessWidget { final BoxDecoration _kSelectedDecoration = new BoxDecoration( border: new Border(bottom: new BorderSide(color: theme.dividerColor)), // The backgroundColor has to be transparent so you can see the ink on the material - backgroundColor: (Theme.of(context).brightness == Brightness.light) ? _kGrey100Opacity : _kGrey300Opacity + color: (Theme.of(context).brightness == Brightness.light) ? _kGrey100Opacity : _kGrey300Opacity ); final BoxDecoration _kUnselectedDecoration = new BoxDecoration( border: new Border(bottom: new BorderSide(color: theme.dividerColor)) diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index bfec061650..5754dfd243 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -253,7 +253,7 @@ class DayPicker extends StatelessWidget { // The selected day gets a circle background highlight, and a contrasting text color. itemStyle = themeData.accentTextTheme.body2; decoration = new BoxDecoration( - backgroundColor: themeData.accentColor, + color: themeData.accentColor, shape: BoxShape.circle ); } else if (disabled) { diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index 9288f1f872..571fe1fa69 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -273,11 +273,8 @@ class DrawerControllerState extends State with SingleTickerPro children: [ new GestureDetector( onTap: close, - child: new DecoratedBox( - decoration: new BoxDecoration( - backgroundColor: _color.evaluate(_controller) - ), - child: new Container(), + child: new Container( + color: _color.evaluate(_controller) ), ), new Align( diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 03cacbd6e8..96b1592c49 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -31,10 +31,10 @@ class _DropdownMenuPainter extends CustomPainter { this.selectedIndex, this.resize, }) : _painter = new BoxDecoration( - // If you add a background image here, you must provide a real + // If you add an image here, you must provide a real // configuration in the paint() function and you must provide some sort // of onChanged callback here. - backgroundColor: color, + color: color, borderRadius: new BorderRadius.circular(2.0), boxShadow: kElevationToShadow[elevation] ).createBoxPainter(), diff --git a/packages/flutter/lib/src/material/grid_tile_bar.dart b/packages/flutter/lib/src/material/grid_tile_bar.dart index f9c981e93e..17052b1cbe 100644 --- a/packages/flutter/lib/src/material/grid_tile_bar.dart +++ b/packages/flutter/lib/src/material/grid_tile_bar.dart @@ -62,7 +62,7 @@ class GridTileBar extends StatelessWidget { Widget build(BuildContext context) { BoxDecoration decoration; if (backgroundColor != null) - decoration = new BoxDecoration(backgroundColor: backgroundColor); + decoration = new BoxDecoration(color: backgroundColor); final List children = []; final EdgeInsets padding = new EdgeInsets.only( diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index c6dece98bd..38b14e24b1 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -287,7 +287,7 @@ class _MaterialState extends State with TickerProviderStateMixin { child: new Container( decoration: new BoxDecoration( borderRadius: radius, - backgroundColor: backgroundColor, + color: backgroundColor, shape: widget.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle ), child: contents diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index 1aa440cff2..63257ef8b6 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -517,7 +517,7 @@ class _MergeableMaterialState extends State with TickerProvid widgets.add( new Container( decoration: new BoxDecoration( - backgroundColor: Theme.of(context).cardColor, + color: Theme.of(context).cardColor, borderRadius: _borderRadius(i - 1, widgets.isEmpty, false), shape: BoxShape.rectangle ), @@ -588,7 +588,7 @@ class _MergeableMaterialState extends State with TickerProvid widgets.add( new Container( decoration: new BoxDecoration( - backgroundColor: Theme.of(context).cardColor, + color: Theme.of(context).cardColor, borderRadius: _borderRadius(i - 1, widgets.isEmpty, true), shape: BoxShape.rectangle ), diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index a4063c1e2f..e63d848baf 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -388,9 +388,7 @@ class PaginatedDataTableState extends State { // TODO(ianh): This decoration will prevent ink splashes from being visible. // Instead, we should have a widget that prints the decoration on the material. // See https://github.com/flutter/flutter/issues/3782 - decoration: _selectedRowCount > 0 ? new BoxDecoration( - backgroundColor: themeData.secondaryHeaderColor - ) : null, + color: _selectedRowCount > 0 ? themeData.secondaryHeaderColor : null, child: new Row( mainAxisAlignment: MainAxisAlignment.end, children: headerWidgets diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 217f4f1621..6daa246f60 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -225,9 +225,7 @@ class _StepperState extends State with TickerProviderStateMixin { return new Container( width: visible ? 1.0 : 0.0, height: 16.0, - decoration: new BoxDecoration( - backgroundColor: Colors.grey.shade400, - ), + color: Colors.grey.shade400, ); } @@ -276,7 +274,7 @@ class _StepperState extends State with TickerProviderStateMixin { curve: Curves.fastOutSlowIn, duration: kThemeAnimationDuration, decoration: new BoxDecoration( - backgroundColor: _circleColor(index), + color: _circleColor(index), shape: BoxShape.circle, ), child: new Center( @@ -484,9 +482,7 @@ class _StepperState extends State with TickerProviderStateMixin { child: new SizedBox( width: _isLast(index) ? 0.0 : 1.0, child: new Container( - decoration: new BoxDecoration( - backgroundColor: Colors.grey.shade400, - ), + color: Colors.grey.shade400, ), ), ), @@ -585,9 +581,7 @@ class _StepperState extends State with TickerProviderStateMixin { child: new Container( margin: const EdgeInsets.symmetric(horizontal: 8.0), height: 1.0, - decoration: new BoxDecoration( - backgroundColor: Colors.grey.shade400, - ), + color: Colors.grey.shade400, ), ), ); diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index da61fc049d..a09b76ed9a 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -325,8 +325,8 @@ class _RenderSwitch extends RenderToggleable { BoxDecoration _createDefaultThumbDecoration(Color color, ImageProvider image) { return new BoxDecoration( - backgroundColor: color, - backgroundImage: image == null ? null : new BackgroundImage(image: image), + color: color, + image: image == null ? null : new DecorationImage(image: image), shape: BoxShape.circle, boxShadow: kElevationToShadow[1] ); diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 05ffded24e..322f642d96 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -930,9 +930,9 @@ class TabPageSelectorIndicator extends StatelessWidget { height: 12.0, margin: const EdgeInsets.all(4.0), decoration: new BoxDecoration( - backgroundColor: backgroundColor, + color: backgroundColor, border: new Border.all(color: borderColor), - shape: BoxShape.circle + shape: BoxShape.circle, ), ); } diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 1f71cfcbfd..c2ffde573f 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -275,7 +275,7 @@ class _TooltipOverlay extends StatelessWidget { opacity: 0.9, child: new Container( decoration: new BoxDecoration( - backgroundColor: darkTheme.backgroundColor, + color: darkTheme.backgroundColor, borderRadius: new BorderRadius.circular(2.0) ), height: height, diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index a9a3cb56b5..e7b1b24427 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -192,7 +192,7 @@ class _TwoLevelSublistState extends State with SingleTickerProv Widget buildList(BuildContext context, Widget child) { return new Container( decoration: new BoxDecoration( - backgroundColor: _backgroundColor.evaluate(_easeOutAnimation), + color: _backgroundColor.evaluate(_easeOutAnimation), border: new Border( top: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation)), bottom: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation)) diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index 81341f4c19..7d1ddb385e 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -183,7 +183,7 @@ class _UserAccountsDrawerHeaderState extends State { assert(debugCheckHasMaterial(context)); return new DrawerHeader( decoration: widget.decoration ?? new BoxDecoration( - backgroundColor: Theme.of(context).primaryColor, + color: Theme.of(context).primaryColor, ), margin: widget.margin, child: new Column( diff --git a/packages/flutter/lib/src/painting/box_painter.dart b/packages/flutter/lib/src/painting/box_painter.dart index 1507f22374..c5bb2a2969 100644 --- a/packages/flutter/lib/src/painting/box_painter.dart +++ b/packages/flutter/lib/src/painting/box_painter.dart @@ -964,16 +964,16 @@ void paintImage({ canvas.restore(); } -/// A background image for a box. +/// An image for a box decoration. /// /// The image is painted using [paintImage], which describes the meanings of the /// various fields on this class in more detail. @immutable -class BackgroundImage { - /// Creates a background image. +class DecorationImage { + /// Creates an image to show in a [BoxDecoration]. /// /// The [image] argument must not be null. - const BackgroundImage({ + const DecorationImage({ this.image, this.fit, this.repeat: ImageRepeat.noRepeat, @@ -982,16 +982,16 @@ class BackgroundImage { this.alignment, }); - /// The image to be painted into the background. + /// The image to be painted into the decoration. final ImageProvider image; - /// How the background image should be inscribed into the box. + /// How the image should be inscribed into the box. /// /// The default varies based on the other fields. See the discussion at /// [paintImage]. final BoxFit fit; - /// How to paint any portions of the box not covered by the background image. + /// How to paint any portions of the box not covered by the image. final ImageRepeat repeat; /// The center slice for a nine-patch image. @@ -1003,7 +1003,7 @@ class BackgroundImage { /// the center slice will be stretched only vertically. final Rect centerSlice; - /// A color filter to apply to the background image before painting it. + /// A color filter to apply to the image before painting it. final ColorFilter colorFilter; /// How to align the image within its bounds. @@ -1019,9 +1019,9 @@ class BackgroundImage { bool operator ==(dynamic other) { if (identical(this, other)) return true; - if (other is! BackgroundImage) + if (runtimeType != other.runtimeType) return false; - final BackgroundImage typedOther = other; + final DecorationImage typedOther = other; return image == typedOther.image && fit == typedOther.fit && repeat == typedOther.repeat && @@ -1034,19 +1034,19 @@ class BackgroundImage { int get hashCode => hashValues(image, fit, repeat, centerSlice, colorFilter, alignment); @override - String toString() => 'BackgroundImage($image, $fit, $repeat)'; + String toString() => '$runtimeType($image, $fit, $repeat)'; } /// An immutable description of how to paint a box. /// /// The following example uses the [Container] widget from the widgets layer to -/// draw a background image with a border: +/// draw an image with a border: /// /// ```dart /// new Container( /// decoration: new BoxDecoration( -/// backgroundColor: const Color(0xff7c94b6), -/// backgroundImage: new BackgroundImage( +/// color: const Color(0xff7c94b6), +/// image: new DecorationImage( /// image: new ExactAssetImage('images/flowers.jpeg'), /// fit: BoxFit.cover, /// ), @@ -1060,8 +1060,8 @@ class BackgroundImage { class BoxDecoration extends Decoration { /// Creates a box decoration. /// - /// * If [backgroundColor] is null, this decoration does not paint a background color. - /// * If [backgroundImage] is null, this decoration does not paint a background image. + /// * If [color] is null, this decoration does not paint a background color. + /// * If [image] is null, this decoration does not paint a background image. /// * If [border] is null, this decoration does not paint a border. /// * If [borderRadius] is null, this decoration uses more efficient background /// painting commands. The [borderRadius] argument must be be null if [shape] is @@ -1069,8 +1069,8 @@ class BoxDecoration extends Decoration { /// * If [boxShadow] is null, this decoration does not paint a shadow. /// * If [gradient] is null, this decoration does not paint gradients. const BoxDecoration({ - this.backgroundColor, - this.backgroundImage, + this.color, + this.image, this.border, this.borderRadius, this.boxShadow, @@ -1092,13 +1092,13 @@ class BoxDecoration extends Decoration { /// /// The color is filled into the shape of the box (e.g., either a rectangle, /// potentially with a border radius, or a circle). - final Color backgroundColor; + final Color color; /// An image to paint above the background color. If [shape] is [BoxShape.circle] /// then the image is clipped to the circle's boundary. - final BackgroundImage backgroundImage; + final DecorationImage image; - /// A border to draw above the background. + /// A border to draw above the background [color] or [image]. final Border border; /// If non-null, the corners of this box are rounded by this [BorderRadius]. @@ -1106,13 +1106,15 @@ class BoxDecoration extends Decoration { /// Applies only to boxes with rectangular shapes. final BorderRadius borderRadius; - /// A list of shadows cast by this box behind the background. + /// A list of shadows cast by this box behind the box. + /// + /// The shadow follows the [shape] of the box. final List boxShadow; - /// A gradient to use when filling the background. + /// A gradient to use when filling the box. final Gradient gradient; - /// The shape to fill the background color into and to cast as a shadow. + /// The shape to fill the background [color] into and to cast as the [boxShadow]. final BoxShape shape; /// The inset space occupied by the border. @@ -1123,8 +1125,8 @@ class BoxDecoration extends Decoration { BoxDecoration scale(double factor) { // TODO(abarth): Scale ALL the things. return new BoxDecoration( - backgroundColor: Color.lerp(null, backgroundColor, factor), - backgroundImage: backgroundImage, + color: Color.lerp(null, color, factor), + image: image, border: Border.lerp(null, border, factor), borderRadius: BorderRadius.lerp(null, borderRadius, factor), boxShadow: BoxShadow.lerpList(null, boxShadow, factor), @@ -1150,8 +1152,8 @@ class BoxDecoration extends Decoration { return a.scale(1.0 - t); // TODO(abarth): lerp ALL the fields. return new BoxDecoration( - backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), - backgroundImage: b.backgroundImage, + color: Color.lerp(a.color, b.color, t), + image: b.image, border: Border.lerp(a.border, b.border, t), borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t), boxShadow: BoxShadow.lerpList(a.boxShadow, b.boxShadow, t), @@ -1178,11 +1180,11 @@ class BoxDecoration extends Decoration { bool operator ==(dynamic other) { if (identical(this, other)) return true; - if (other is! BoxDecoration) + if (runtimeType != other.runtimeType) return false; final BoxDecoration typedOther = other; - return backgroundColor == typedOther.backgroundColor && - backgroundImage == typedOther.backgroundImage && + return color == typedOther.color && + image == typedOther.image && border == typedOther.border && borderRadius == typedOther.borderRadius && boxShadow == typedOther.boxShadow && @@ -1193,8 +1195,8 @@ class BoxDecoration extends Decoration { @override int get hashCode { return hashValues( - backgroundColor, - backgroundImage, + color, + image, border, borderRadius, boxShadow, @@ -1209,10 +1211,10 @@ class BoxDecoration extends Decoration { @override String toString([String prefix = '', String indentPrefix]) { final List result = []; - if (backgroundColor != null) - result.add('${prefix}backgroundColor: $backgroundColor'); - if (backgroundImage != null) - result.add('${prefix}backgroundImage: $backgroundImage'); + if (color != null) + result.add('${prefix}color: $color'); + if (image != null) + result.add('${prefix}image: $image'); if (border != null) result.add('${prefix}border: $border'); if (borderRadius != null) @@ -1260,7 +1262,7 @@ class BoxDecoration extends Decoration { @override _BoxDecorationPainter createBoxPainter([VoidCallback onChanged]) { - assert(onChanged != null || backgroundImage == null); + assert(onChanged != null || image == null); return new _BoxDecorationPainter(this, onChanged); } } @@ -1282,8 +1284,8 @@ class _BoxDecorationPainter extends BoxPainter { (_decoration.gradient != null && _rectForCachedBackgroundPaint != rect)) { final Paint paint = new Paint(); - if (_decoration.backgroundColor != null) - paint.color = _decoration.backgroundColor; + if (_decoration.color != null) + paint.color = _decoration.color; if (_decoration.gradient != null) { paint.shader = _decoration.gradient.createShader(rect); @@ -1329,7 +1331,7 @@ class _BoxDecorationPainter extends BoxPainter { } void _paintBackgroundColor(Canvas canvas, Rect rect) { - if (_decoration.backgroundColor != null || _decoration.gradient != null) + if (_decoration.color != null || _decoration.gradient != null) _paintBox(canvas, rect, _getBackgroundPaint(rect)); } @@ -1337,7 +1339,7 @@ class _BoxDecorationPainter extends BoxPainter { ImageInfo _image; void _paintBackgroundImage(Canvas canvas, Rect rect, ImageConfiguration configuration) { - final BackgroundImage backgroundImage = _decoration.backgroundImage; + final DecorationImage backgroundImage = _decoration.image; if (backgroundImage == null) return; final ImageStream newImageStream = backgroundImage.image.resolve(configuration); diff --git a/packages/flutter/lib/src/widgets/container.dart b/packages/flutter/lib/src/widgets/container.dart index 3199352e6e..83661f3643 100644 --- a/packages/flutter/lib/src/widgets/container.dart +++ b/packages/flutter/lib/src/widgets/container.dart @@ -122,7 +122,7 @@ class Container extends StatelessWidget { this.margin, this.transform, this.child, - }) : decoration = decoration ?? (color != null ? new BoxDecoration(backgroundColor: color) : null), + }) : decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null), constraints = (width != null || height != null) ? constraints?.tighten(width: width, height: height) @@ -161,6 +161,10 @@ class Container extends StatelessWidget { final EdgeInsets padding; /// The decoration to paint behind the [child]. + /// + /// A shorthand for specifying just a solid color is available in the + /// constructor: set the `color` argument instead of the `decoration` + /// argument. final Decoration decoration; /// The decoration to paint in front of the [child]. @@ -234,18 +238,18 @@ class Container extends StatelessWidget { @override void debugFillDescription(List description) { super.debugFillDescription(description); - if (constraints != null) - description.add('$constraints'); if (alignment != null) description.add('$alignment'); + if (padding != null) + description.add('padding: $padding'); if (decoration != null) description.add('bg: $decoration'); if (foregroundDecoration != null) description.add('fg: $foregroundDecoration'); + if (constraints != null) + description.add('$constraints'); if (margin != null) description.add('margin: $margin'); - if (padding != null) - description.add('padding: $padding'); if (transform != null) description.add('has transform'); } diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index d6f80d8d50..0187a39b64 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -241,134 +241,155 @@ class AnimatedContainer extends ImplicitlyAnimatedWidget { /// The [curve] and [duration] arguments must not be null. AnimatedContainer({ Key key, - this.child, - this.constraints, - this.decoration, - this.foregroundDecoration, - this.margin, + this.alignment, this.padding, + Color color, + Decoration decoration, + this.foregroundDecoration, + double width, + double height, + BoxConstraints constraints, + this.margin, this.transform, - this.width, - this.height, + this.child, Curve curve: Curves.linear, @required Duration duration, - }) : super(key: key, curve: curve, duration: duration) { - assert(decoration == null || decoration.debugAssertIsValid()); - assert(foregroundDecoration == null || foregroundDecoration.debugAssertIsValid()); + }) : decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null), + constraints = + (width != null || height != null) + ? constraints?.tighten(width: width, height: height) + ?? new BoxConstraints.tightFor(width: width, height: height) + : constraints, + super(key: key, curve: curve, duration: duration) { assert(margin == null || margin.isNonNegative); assert(padding == null || padding.isNonNegative); + assert(decoration == null || decoration.debugAssertIsValid()); assert(constraints == null || constraints.debugAssertIsValid()); + assert(color == null || decoration == null, + 'Cannot provide both a color and a decoration\n' + 'The color argument is just a shorthand for "decoration: new BoxDecoration(backgroundColor: color)".' + ); } - /// The widget below this widget in the tree. + /// The [child] contained by the container. + /// + /// If null, and if the [constraints] are unbounded or also null, the + /// container will expand to fill all available space in its parent, unless + /// the parent provides unbounded constraints, in which case the container + /// will attempt to be as small as possible. final Widget child; - /// Additional constraints to apply to the child. - final BoxConstraints constraints; + /// Align the [child] within the container. + /// + /// If non-null, the container will expand to fill its parent and position its + /// child within itself according to the given value. If the incoming + /// constraints are unbounded, then the child will be shrink-wrapped instead. + /// + /// Ignored if [child] is null. + final FractionalOffset alignment; - /// The decoration to paint behind the child. + /// Empty space to inscribe inside the [decoration]. The [child], if any, is + /// placed inside this padding. + final EdgeInsets padding; + + /// The decoration to paint behind the [child]. + /// + /// A shorthand for specifying just a solid color is available in the + /// constructor: set the `color` argument instead of the `decoration` + /// argument. final Decoration decoration; /// The decoration to paint in front of the child. final Decoration foregroundDecoration; - /// Empty space to surround the decoration. - final EdgeInsets margin; + /// Additional constraints to apply to the child. + /// + /// The constructor `width` and `height` arguments are combined with the + /// `constraints` argument to set this property. + /// + /// The [padding] goes inside the constraints. + final BoxConstraints constraints; - /// Empty space to inscribe inside the decoration. - final EdgeInsets padding; + /// Empty space to surround the [decoration] and [child]. + final EdgeInsets margin; /// The transformation matrix to apply before painting the container. final Matrix4 transform; - /// If non-null, requires the decoration to have this width. - final double width; - - /// If non-null, requires the decoration to have this height. - final double height; - @override _AnimatedContainerState createState() => new _AnimatedContainerState(); @override void debugFillDescription(List description) { super.debugFillDescription(description); - if (constraints != null) - description.add('$constraints'); - if (decoration != null) - description.add('has background'); - if (foregroundDecoration != null) - description.add('has foreground'); - if (margin != null) - description.add('margin: $margin'); + if (alignment != null) + description.add('$alignment'); if (padding != null) description.add('padding: $padding'); + if (decoration != null) + description.add('bg: $decoration'); + if (foregroundDecoration != null) + description.add('fg: $foregroundDecoration'); + if (constraints != null) + description.add('$constraints'); + if (margin != null) + description.add('margin: $margin'); if (transform != null) description.add('has transform'); - if (width != null) - description.add('width: $width'); - if (height != null) - description.add('height: $height'); } } class _AnimatedContainerState extends AnimatedWidgetBaseState { - BoxConstraintsTween _constraints; + FractionalOffsetTween _alignment; + EdgeInsetsTween _padding; DecorationTween _decoration; DecorationTween _foregroundDecoration; + BoxConstraintsTween _constraints; EdgeInsetsTween _margin; - EdgeInsetsTween _padding; Matrix4Tween _transform; - Tween _width; - Tween _height; @override void forEachTween(TweenVisitor visitor) { - // TODO(ianh): Use constructor tear-offs when it becomes possible - _constraints = visitor(_constraints, widget.constraints, (dynamic value) => new BoxConstraintsTween(begin: value)); + _alignment = visitor(_alignment, widget.alignment, (dynamic value) => new FractionalOffsetTween(begin: value)); + _padding = visitor(_padding, widget.padding, (dynamic value) => new EdgeInsetsTween(begin: value)); _decoration = visitor(_decoration, widget.decoration, (dynamic value) => new DecorationTween(begin: value)); _foregroundDecoration = visitor(_foregroundDecoration, widget.foregroundDecoration, (dynamic value) => new DecorationTween(begin: value)); + _constraints = visitor(_constraints, widget.constraints, (dynamic value) => new BoxConstraintsTween(begin: value)); _margin = visitor(_margin, widget.margin, (dynamic value) => new EdgeInsetsTween(begin: value)); - _padding = visitor(_padding, widget.padding, (dynamic value) => new EdgeInsetsTween(begin: value)); _transform = visitor(_transform, widget.transform, (dynamic value) => new Matrix4Tween(begin: value)); - _width = visitor(_width, widget.width, (dynamic value) => new Tween(begin: value)); - _height = visitor(_height, widget.height, (dynamic value) => new Tween(begin: value)); } @override Widget build(BuildContext context) { return new Container( child: widget.child, - constraints: _constraints?.evaluate(animation), + alignment: _alignment?.evaluate(animation), + padding: _padding?.evaluate(animation), decoration: _decoration?.evaluate(animation), foregroundDecoration: _foregroundDecoration?.evaluate(animation), + constraints: _constraints?.evaluate(animation), margin: _margin?.evaluate(animation), - padding: _padding?.evaluate(animation), transform: _transform?.evaluate(animation), - width: _width?.evaluate(animation), - height: _height?.evaluate(animation) ); } @override void debugFillDescription(List description) { super.debugFillDescription(description); - if (_constraints != null) - description.add('has constraints'); - if (_decoration != null) - description.add('has background'); - if (_foregroundDecoration != null) - description.add('has foreground'); - if (_margin != null) - description.add('has margin'); + if (_alignment != null) + description.add('$_alignment'); if (_padding != null) - description.add('has padding'); + description.add('padding: $_padding'); + if (_decoration != null) + description.add('bg: $_decoration'); + if (_foregroundDecoration != null) + description.add('fg: $_foregroundDecoration'); + if (_constraints != null) + description.add('$_constraints'); + if (_margin != null) + description.add('margin: $_margin'); if (_transform != null) description.add('has transform'); - if (_width != null) - description.add('has width'); - if (_height != null) - description.add('has height'); } } @@ -475,7 +496,6 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState visitor) { - // TODO(ianh): Use constructor tear-offs when it becomes possible _left = visitor(_left, widget.left, (dynamic value) => new Tween(begin: value)); _top = visitor(_top, widget.top, (dynamic value) => new Tween(begin: value)); _right = visitor(_right, widget.right, (dynamic value) => new Tween(begin: value)); @@ -559,7 +579,6 @@ class _AnimatedOpacityState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { - // TODO(ianh): Use constructor tear-offs when it becomes possible _opacity = visitor(_opacity, widget.opacity, (dynamic value) => new Tween(begin: value)); } @@ -613,7 +632,6 @@ class _AnimatedDefaultTextStyleState extends AnimatedWidgetBaseState visitor) { - // TODO(ianh): Use constructor tear-offs when it becomes possible _style = visitor(_style, widget.style, (dynamic value) => new TextStyleTween(begin: value)); } diff --git a/packages/flutter/lib/src/widgets/modal_barrier.dart b/packages/flutter/lib/src/widgets/modal_barrier.dart index d61d43b522..719fa189ee 100644 --- a/packages/flutter/lib/src/widgets/modal_barrier.dart +++ b/packages/flutter/lib/src/widgets/modal_barrier.dart @@ -38,7 +38,7 @@ class ModalBarrier extends StatelessWidget { constraints: const BoxConstraints.expand(), child: color == null ? null : new DecoratedBox( decoration: new BoxDecoration( - backgroundColor: color + color: color ) ) ) diff --git a/packages/flutter/test/material/circle_avatar_test.dart b/packages/flutter/test/material/circle_avatar_test.dart index 6878d602ec..1d5466ebbc 100644 --- a/packages/flutter/test/material/circle_avatar_test.dart +++ b/packages/flutter/test/material/circle_avatar_test.dart @@ -24,7 +24,7 @@ void main() { expect(box.size.height, equals(100.0)); final RenderDecoratedBox child = box.child; final BoxDecoration decoration = child.decoration; - expect(decoration.backgroundColor, equals(backgroundColor)); + expect(decoration.color, equals(backgroundColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); expect(paragraph.text.style.color, equals(Colors.white)); @@ -48,7 +48,7 @@ void main() { expect(box.size.height, equals(40.0)); final RenderDecoratedBox child = box.child; final BoxDecoration decoration = child.decoration; - expect(decoration.backgroundColor, equals(fallback.primaryColor)); + expect(decoration.color, equals(fallback.primaryColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); expect(paragraph.text.style.color, equals(foregroundColor)); @@ -73,7 +73,7 @@ void main() { final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderDecoratedBox child = box.child; final BoxDecoration decoration = child.decoration; - expect(decoration.backgroundColor, equals(theme.primaryColor)); + expect(decoration.color, equals(theme.primaryColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); expect(paragraph.text.style.color, equals(theme.primaryTextTheme.title.color)); diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index e4a3497d5b..83a8f28b39 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -24,9 +24,7 @@ void main() { content: new Container( height: 5000.0, width: 300.0, - decoration: new BoxDecoration( - backgroundColor: Colors.green[500] - ) + color: Colors.green[500], ), actions: [ new FlatButton( diff --git a/packages/flutter/test/material/grid_title_test.dart b/packages/flutter/test/material/grid_title_test.dart index 7a36db30f5..b072303583 100644 --- a/packages/flutter/test/material/grid_title_test.dart +++ b/packages/flutter/test/material/grid_title_test.dart @@ -20,7 +20,7 @@ void main() { ), child: new DecoratedBox( decoration: new BoxDecoration( - backgroundColor: Colors.green[500], + color: Colors.green[500], ), ), footer: new GridTileBar( diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index 1d4dd4a711..b96bc33d11 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -80,9 +80,7 @@ void main() { children: [ new Container( height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), ], ), diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index a6651c0884..b089f51281 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -269,9 +269,7 @@ void main() { home: new Scaffold( body: new SingleChildScrollView( child: new Container( - decoration: new BoxDecoration( - backgroundColor: Colors.amber[500], - ), + color: Colors.amber[500], height: 5000.0, child: const Text('body'), ), diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index f9d848532e..0e4b9608e6 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -406,9 +406,7 @@ void main() { child: new Container( width: 100.0, height: 100.0, - decoration: new BoxDecoration( - backgroundColor: Colors.green[500] - ) + color: Colors.green[500], ) ) ) @@ -483,9 +481,7 @@ void main() { child: new Container( width: 100.0, height: 100.0, - decoration: new BoxDecoration( - backgroundColor: Colors.green[500] - ) + color: Colors.green[500], ) ) ) diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart index f536c3b8cb..92db077964 100644 --- a/packages/flutter/test/painting/decoration_test.dart +++ b/packages/flutter/test/painting/decoration_test.dart @@ -52,12 +52,12 @@ class AsyncTestImageProvider extends ImageProvider { } } -class BackgroundImageProvider extends ImageProvider { +class DelayedImageProvider extends ImageProvider { final Completer _completer = new Completer(); @override - Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + Future obtainKey(ImageConfiguration configuration) { + return new SynchronousFuture(this); } @override @@ -66,7 +66,7 @@ class BackgroundImageProvider extends ImageProvider { } @override - ImageStreamCompleter load(BackgroundImageProvider key) { + ImageStreamCompleter load(DelayedImageProvider key) { return new OneFrameImageStreamCompleter(_completer.future); } @@ -91,24 +91,24 @@ class TestImage extends ui.Image { void main() { test("Decoration.lerp()", () { - final BoxDecoration a = const BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)); - final BoxDecoration b = const BoxDecoration(backgroundColor: const Color(0x00000000)); + final BoxDecoration a = const BoxDecoration(color: const Color(0xFFFFFFFF)); + final BoxDecoration b = const BoxDecoration(color: const Color(0x00000000)); BoxDecoration c = Decoration.lerp(a, b, 0.0); - expect(c.backgroundColor, equals(a.backgroundColor)); + expect(c.color, equals(a.color)); c = Decoration.lerp(a, b, 0.25); - expect(c.backgroundColor, equals(Color.lerp(const Color(0xFFFFFFFF), const Color(0x00000000), 0.25))); + expect(c.color, equals(Color.lerp(const Color(0xFFFFFFFF), const Color(0x00000000), 0.25))); c = Decoration.lerp(a, b, 1.0); - expect(c.backgroundColor, equals(b.backgroundColor)); + expect(c.color, equals(b.color)); }); test("BoxDecorationImageListenerSync", () { final ImageProvider imageProvider = new SynchronousTestImageProvider(); - final BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider); + final DecorationImage backgroundImage = new DecorationImage(image: imageProvider); - final BoxDecoration boxDecoration = new BoxDecoration(backgroundImage: backgroundImage); + final BoxDecoration boxDecoration = new BoxDecoration(image: backgroundImage); bool onChangedCalled = false; final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { onChangedCalled = true; @@ -125,9 +125,9 @@ void main() { test("BoxDecorationImageListenerAsync", () { new FakeAsync().run((FakeAsync async) { final ImageProvider imageProvider = new AsyncTestImageProvider(); - final BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider); + final DecorationImage backgroundImage = new DecorationImage(image: imageProvider); - final BoxDecoration boxDecoration = new BoxDecoration(backgroundImage: backgroundImage); + final BoxDecoration boxDecoration = new BoxDecoration(image: backgroundImage); bool onChangedCalled = false; final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { onChangedCalled = true; @@ -149,13 +149,13 @@ void main() { test("BoxDecoration backgroundImage clip", () { void testDecoration({ BoxShape shape, BorderRadius borderRadius, bool expectClip}) { new FakeAsync().run((FakeAsync async) { - final BackgroundImageProvider imageProvider = new BackgroundImageProvider(); - final BackgroundImage backgroundImage = new BackgroundImage(image: imageProvider); + final DelayedImageProvider imageProvider = new DelayedImageProvider(); + final DecorationImage backgroundImage = new DecorationImage(image: imageProvider); final BoxDecoration boxDecoration = new BoxDecoration( shape: shape, borderRadius: borderRadius, - backgroundImage: backgroundImage, + image: backgroundImage, ); final List invocations = []; @@ -168,7 +168,7 @@ void main() { onChangedCalled = true; }); - // _BoxDecorationPainter._paintBackgroundImage() resolves the background + // _BoxDecorationPainter._paintDecorationImage() resolves the background // image and adds a listener to the resolved image stream. boxPainter.paint(canvas, Offset.zero, imageConfiguration); imageProvider.complete(); diff --git a/packages/flutter/test/rendering/box_test.dart b/packages/flutter/test/rendering/box_test.dart index 5a3593d910..e788f13938 100644 --- a/packages/flutter/test/rendering/box_test.dart +++ b/packages/flutter/test/rendering/box_test.dart @@ -12,7 +12,7 @@ void main() { test("should size to render view", () { final RenderBox root = new RenderDecoratedBox( decoration: new BoxDecoration( - backgroundColor: const Color(0xFF00FF00), + color: const Color(0xFF00FF00), gradient: new RadialGradient( center: FractionalOffset.topLeft, radius: 1.8, colors: [Colors.yellow[500], Colors.blue[500]], @@ -31,7 +31,7 @@ void main() { ); final RenderBox inner = new RenderDecoratedBox( decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), + color: const Color(0xFF00FF00), ), child: size, ); @@ -46,7 +46,7 @@ void main() { ); final RenderBox outer = new RenderDecoratedBox( decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) + color: const Color(0xFF0000FF), ), child: flex, ); diff --git a/packages/flutter/test/rendering/stack_test.dart b/packages/flutter/test/rendering/stack_test.dart index 5be24bde55..cb7f768b9a 100644 --- a/packages/flutter/test/rendering/stack_test.dart +++ b/packages/flutter/test/rendering/stack_test.dart @@ -15,15 +15,15 @@ void main() { final RenderBox red = new RenderDecoratedBox( decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFF0000) + color: const Color(0xFFFF0000), ), child: size ); final RenderBox green = new RenderDecoratedBox( decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFF0000) - ) + color: const Color(0xFFFF0000), + ), ); final RenderBox stack = new RenderStack(children: [red, green]); diff --git a/packages/flutter/test/widgets/animated_container_test.dart b/packages/flutter/test/widgets/animated_container_test.dart index 6f159eabee..ce83b6c68c 100644 --- a/packages/flutter/test/widgets/animated_container_test.dart +++ b/packages/flutter/test/widgets/animated_container_test.dart @@ -10,8 +10,8 @@ void main() { testWidgets('AnimatedContainer.debugFillDescription', (WidgetTester tester) async { final AnimatedContainer container = new AnimatedContainer( constraints: const BoxConstraints.tightFor(width: 17.0, height: 23.0), - decoration: const BoxDecoration(backgroundColor: const Color(0xFF00FF00)), - foregroundDecoration: const BoxDecoration(backgroundColor: const Color(0x7F0000FF)), + decoration: const BoxDecoration(color: const Color(0xFF00FF00)), + foregroundDecoration: const BoxDecoration(color: const Color(0x7F0000FF)), margin: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(7.0), transform: new Matrix4.translationValues(4.0, 3.0, 0.0), @@ -28,11 +28,11 @@ void main() { final GlobalKey key = new GlobalKey(); final BoxDecoration decorationA = const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) + color: const Color(0xFF00FF00), ); final BoxDecoration decorationB = const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) + color: const Color(0xFF0000FF), ); BoxDecoration actualDecoration; @@ -47,7 +47,7 @@ void main() { final RenderDecoratedBox box = key.currentContext.findRenderObject(); actualDecoration = box.decoration; - expect(actualDecoration.backgroundColor, equals(decorationA.backgroundColor)); + expect(actualDecoration.color, equals(decorationA.color)); await tester.pumpWidget( new AnimatedContainer( @@ -59,21 +59,19 @@ void main() { expect(key.currentContext.findRenderObject(), equals(box)); actualDecoration = box.decoration; - expect(actualDecoration.backgroundColor, equals(decorationA.backgroundColor)); + expect(actualDecoration.color, equals(decorationA.color)); await tester.pump(const Duration(seconds: 1)); actualDecoration = box.decoration; - expect(actualDecoration.backgroundColor, equals(decorationB.backgroundColor)); + expect(actualDecoration.color, equals(decorationB.color)); }); testWidgets('AnimatedContainer overanimate test', (WidgetTester tester) async { await tester.pumpWidget( new AnimatedContainer( duration: const Duration(milliseconds: 200), - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ); expect(tester.binding.transientCallbackCount, 0); @@ -82,9 +80,7 @@ void main() { await tester.pumpWidget( new AnimatedContainer( duration: const Duration(milliseconds: 200), - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ); expect(tester.binding.transientCallbackCount, 0); @@ -93,9 +89,7 @@ void main() { await tester.pumpWidget( new AnimatedContainer( duration: const Duration(milliseconds: 200), - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) - ) + color: const Color(0xFF0000FF), ) ); expect(tester.binding.transientCallbackCount, 1); // this is the only time an animation should have started! @@ -104,9 +98,7 @@ void main() { await tester.pumpWidget( new AnimatedContainer( duration: const Duration(milliseconds: 200), - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) - ) + color: const Color(0xFF0000FF), ) ); expect(tester.binding.transientCallbackCount, 0); diff --git a/packages/flutter/test/widgets/box_decoration_test.dart b/packages/flutter/test/widgets/box_decoration_test.dart index 123652174f..7adf5fa51b 100644 --- a/packages/flutter/test/widgets/box_decoration_test.dart +++ b/packages/flutter/test/widgets/box_decoration_test.dart @@ -16,7 +16,7 @@ void main() { decoration: new BoxDecoration( shape: BoxShape.circle, border: new Border.all(width: 10.0, color: const Color(0x80FF00FF)), - backgroundColor: Colors.teal[600] + color: Colors.teal[600] ) ) ); diff --git a/packages/flutter/test/widgets/container_test.dart b/packages/flutter/test/widgets/container_test.dart index 96ec7da23a..1b27e8a3bb 100644 --- a/packages/flutter/test/widgets/container_test.dart +++ b/packages/flutter/test/widgets/container_test.dart @@ -12,8 +12,9 @@ void main() { final Container container = new Container( alignment: FractionalOffset.bottomRight, padding: const EdgeInsets.all(7.0), - decoration: const BoxDecoration(backgroundColor: const Color(0xFF00FF00)), - foregroundDecoration: const BoxDecoration(backgroundColor: const Color(0x7F0000FF)), + // uses color, not decoration: + color: const Color(0xFF00FF00), + foregroundDecoration: const BoxDecoration(color: const Color(0x7F0000FF)), width: 53.0, height: 76.0, constraints: const BoxConstraints( @@ -27,7 +28,8 @@ void main() { width: 25.0, height: 33.0, child: const DecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0xFFFFFF00)), + // uses decoration, not color: + decoration: const BoxDecoration(color: const Color(0xFFFFFF00)), ), ), ); diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index 0b3e0ba716..ace5891501 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -993,16 +993,12 @@ void main() { }, child: new Draggable( child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFFFF00) - ) + color: const Color(0xFFFFFF00), ), feedback: new Container( width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFF0000) - ) + color: const Color(0xFFFF0000), ) ) ) @@ -1028,16 +1024,12 @@ void main() { onTap: () { /* registers a tap recognizer */ }, child: new Draggable( child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFFFF00) - ) + color: const Color(0xFFFFFF00), ), feedback: new Container( width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFF0000) - ) + color: const Color(0xFFFF0000), ) ) ) diff --git a/packages/flutter/test/widgets/drawer_test.dart b/packages/flutter/test/widgets/drawer_test.dart index b22b623333..c91d8c3170 100644 --- a/packages/flutter/test/widgets/drawer_test.dart +++ b/packages/flutter/test/widgets/drawer_test.dart @@ -83,9 +83,7 @@ void main() { const Text('drawer'), new Container( height: 1000.0, - decoration: new BoxDecoration( - backgroundColor: Colors.blue[500] - ) + color: Colors.blue[500], ), ] ) diff --git a/packages/flutter/test/widgets/ensure_visible_test.dart b/packages/flutter/test/widgets/ensure_visible_test.dart index b7e5b2e5bc..48e61fc317 100644 --- a/packages/flutter/test/widgets/ensure_visible_test.dart +++ b/packages/flutter/test/widgets/ensure_visible_test.dart @@ -192,9 +192,7 @@ void main() { key: const ValueKey(0), width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFFFFFF), - ), + color: const Color(0xFFFFFFFF), ), ), ), @@ -444,9 +442,7 @@ void main() { key: const ValueKey(0), width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFFFFFF), - ), + color: const Color(0xFFFFFFFF), ), ), ), diff --git a/packages/flutter/test/widgets/flex_test.dart b/packages/flutter/test/widgets/flex_test.dart index 123cc91e58..72ce579294 100644 --- a/packages/flutter/test/widgets/flex_test.dart +++ b/packages/flutter/test/widgets/flex_test.dart @@ -12,9 +12,7 @@ void main() { bool didReceiveTap = false; await tester.pumpWidget( new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), child: new Stack( children: [ new Positioned( @@ -27,8 +25,7 @@ void main() { didReceiveTap = true; }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF)), + color: const Color(0xFF0000FF), width: 100.0, height: 100.0, child: const Center( diff --git a/packages/flutter/test/widgets/flow_test.dart b/packages/flutter/test/widgets/flow_test.dart index 4fca0f6504..237ba6345d 100644 --- a/packages/flutter/test/widgets/flow_test.dart +++ b/packages/flutter/test/widgets/flow_test.dart @@ -43,9 +43,7 @@ void main() { child: new Container( width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) - ), + color: const Color(0xFF0000FF), child: new Text('$i') ) ); diff --git a/packages/flutter/test/widgets/gesture_detector_test.dart b/packages/flutter/test/widgets/gesture_detector_test.dart index 11897b99ef..92f0a5bec8 100644 --- a/packages/flutter/test/widgets/gesture_detector_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_test.dart @@ -22,9 +22,7 @@ void main() { didEndDrag = true; }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ); @@ -69,9 +67,7 @@ void main() { onHorizontalDragUpdate: (DragUpdateDetails details) { fail("gesture should not match"); }, onHorizontalDragEnd: (DragEndDetails details) { fail("gesture should not match"); }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ); await tester.pumpWidget(widget); @@ -107,9 +103,7 @@ void main() { didEndPan = true; }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ) ); @@ -141,9 +135,7 @@ void main() { child: new Container( width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ), new Container( diff --git a/packages/flutter/test/widgets/grid_view_test.dart b/packages/flutter/test/widgets/grid_view_test.dart index 16a756c497..a44517657c 100644 --- a/packages/flutter/test/widgets/grid_view_test.dart +++ b/packages/flutter/test/widgets/grid_view_test.dart @@ -27,9 +27,7 @@ void main() { log.add(state); }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), child: new Text(state), ), ); @@ -95,9 +93,7 @@ void main() { log.add(state); }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), child: new Text(state), ), ); @@ -310,7 +306,7 @@ void main() { final Container container = new Container( decoration: const BoxDecoration( - backgroundColor: green, + color: green, ), ); diff --git a/packages/flutter/test/widgets/implicit_animations_test.dart b/packages/flutter/test/widgets/implicit_animations_test.dart index 257f3922ab..2680603168 100644 --- a/packages/flutter/test/widgets/implicit_animations_test.dart +++ b/packages/flutter/test/widgets/implicit_animations_test.dart @@ -20,11 +20,11 @@ void main() { testWidgets('DecorationTween control test', (WidgetTester tester) async { final DecorationTween tween = new DecorationTween( - begin: const BoxDecoration(backgroundColor: const Color(0xFF00FF00)), - end: const BoxDecoration(backgroundColor: const Color(0xFFFFFF00)) + begin: const BoxDecoration(color: const Color(0xFF00FF00)), + end: const BoxDecoration(color: const Color(0xFFFFFF00)) ); final BoxDecoration result = tween.lerp(0.25); - expect(result.backgroundColor, const Color(0xFF3FFF00)); + expect(result.color, const Color(0xFF3FFF00)); }); testWidgets('EdgeInsetsTween control test', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/list_view_misc_test.dart b/packages/flutter/test/widgets/list_view_misc_test.dart index 6d941421cf..8762187d99 100644 --- a/packages/flutter/test/widgets/list_view_misc_test.dart +++ b/packages/flutter/test/widgets/list_view_misc_test.dart @@ -72,21 +72,17 @@ void main() { reverse: reverse, children: [ new GestureDetector( - onTap: () { ++first; }, + onTap: () { first += 1; }, child: new Container( height: 350.0, // more than half the height of the test area - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) - ) + color: const Color(0xFF00FF00), ) ), new GestureDetector( - onTap: () { ++second; }, + onTap: () { second += 1; }, child: new Container( height: 350.0, // more than half the height of the test area - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) - ) + color: const Color(0xFF0000FF), ) ) ] diff --git a/packages/flutter/test/widgets/list_view_viewporting_test.dart b/packages/flutter/test/widgets/list_view_viewporting_test.dart index 474e3a60ed..4e192f19b8 100644 --- a/packages/flutter/test/widgets/list_view_viewporting_test.dart +++ b/packages/flutter/test/widgets/list_view_viewporting_test.dart @@ -201,9 +201,7 @@ void main() { key: new ValueKey(index), width: 500.0, // this should be ignored height: 220.0, - decoration: new BoxDecoration( - backgroundColor: Theme.of(context).primaryColor, - ), + color: Theme.of(context).primaryColor, child: new Text('$index'), ); }; @@ -223,7 +221,7 @@ void main() { DecoratedBox widget = tester.firstWidget(find.byType(DecoratedBox)); BoxDecoration decoraton = widget.decoration; - expect(decoraton.backgroundColor, equals(Colors.blue[500])); + expect(decoraton.color, equals(Colors.blue[500])); setState(() { themeData = new ThemeData(primarySwatch: Colors.green); @@ -233,7 +231,7 @@ void main() { widget = tester.firstWidget(find.byType(DecoratedBox)); decoraton = widget.decoration; - expect(decoraton.backgroundColor, equals(Colors.green[500])); + expect(decoraton.color, equals(Colors.green[500])); }); testWidgets('ListView padding', (WidgetTester tester) async { @@ -242,9 +240,7 @@ void main() { key: new ValueKey(index), width: 500.0, // this should be ignored height: 220.0, - decoration: new BoxDecoration( - backgroundColor: Colors.green[500] - ), + color: Colors.green[500], child: new Text('$index'), ); }; diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 9089394c19..8fbeddb6ab 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -13,11 +13,9 @@ class FirstWidget extends StatelessWidget { Navigator.pushNamed(context, '/second'); }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFFFF00) - ), - child: const Text('X') - ) + color: const Color(0xFFFFFF00), + child: const Text('X'), + ), ); } } @@ -33,11 +31,9 @@ class SecondWidgetState extends State { return new GestureDetector( onTap: () => Navigator.pop(context), child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFFFF00FF) - ), - child: const Text('Y') - ) + color: const Color(0xFFFF00FF), + child: const Text('Y'), + ), ); } } diff --git a/packages/flutter/test/widgets/overscroll_indicator_test.dart b/packages/flutter/test/widgets/overscroll_indicator_test.dart index 75a7e85a2e..5f2e78a0d4 100644 --- a/packages/flutter/test/widgets/overscroll_indicator_test.dart +++ b/packages/flutter/test/widgets/overscroll_indicator_test.dart @@ -210,9 +210,7 @@ void main() { new Container( width: 2000.0, height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), ], ), diff --git a/packages/flutter/test/widgets/page_transitions_test.dart b/packages/flutter/test/widgets/page_transitions_test.dart index 942b8ff960..9defaf5ecd 100644 --- a/packages/flutter/test/widgets/page_transitions_test.dart +++ b/packages/flutter/test/widgets/page_transitions_test.dart @@ -136,7 +136,7 @@ void main() { '/': (_) => new Scaffold( key: containerKey1, body: new Container( - decoration: const BoxDecoration(backgroundColor: const Color(0xff00ffff)), + color: const Color(0xff00ffff), child: const Hero( tag: kHeroTag, child: const Text('Home') @@ -147,7 +147,7 @@ void main() { key: containerKey2, body: new Container( padding: const EdgeInsets.all(100.0), - decoration: const BoxDecoration(backgroundColor: const Color(0xffff00ff)), + color: const Color(0xffff00ff), child: const Hero( tag: kHeroTag, child: const Text('Settings') diff --git a/packages/flutter/test/widgets/page_view_test.dart b/packages/flutter/test/widgets/page_view_test.dart index 02695f3d2b..2f0bff442c 100644 --- a/packages/flutter/test/widgets/page_view_test.dart +++ b/packages/flutter/test/widgets/page_view_test.dart @@ -22,9 +22,7 @@ void main() { }, child: new Container( height: 200.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), child: new Text(state), ), ); @@ -83,9 +81,7 @@ void main() { children: new List.generate(10, (int i) { return new Container( key: new ValueKey(i), - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), ); }), ), diff --git a/packages/flutter/test/widgets/render_object_widget_test.dart b/packages/flutter/test/widgets/render_object_widget_test.dart index 0be61df876..2cc32bd4d0 100644 --- a/packages/flutter/test/widgets/render_object_widget_test.dart +++ b/packages/flutter/test/widgets/render_object_widget_test.dart @@ -27,9 +27,9 @@ class TestOrientedBox extends SingleChildRenderObjectWidget { final Orientation orientation = MediaQuery.of(context).orientation; switch (orientation) { case Orientation.landscape: - return const BoxDecoration(backgroundColor: const Color(0xFF00FF00)); + return const BoxDecoration(color: const Color(0xFF00FF00)); case Orientation.portrait: - return const BoxDecoration(backgroundColor: const Color(0xFF0000FF)); + return const BoxDecoration(color: const Color(0xFF0000FF)); } assert(orientation != null); return null; @@ -201,7 +201,7 @@ void main() { final RenderDecoratedBox renderBox = tester.renderObject(find.byKey(boxKey)); BoxDecoration decoration = renderBox.decoration; - expect(decoration.backgroundColor, equals(const Color(0xFF00FF00))); + expect(decoration.color, equals(const Color(0xFF00FF00))); await tester.pumpWidget(new MediaQuery( data: const MediaQueryData(size: const Size(300.0, 400.0)), @@ -209,6 +209,6 @@ void main() { )); decoration = renderBox.decoration; - expect(decoration.backgroundColor, equals(const Color(0xFF0000FF))); + expect(decoration.color, equals(const Color(0xFF0000FF))); }); } diff --git a/packages/flutter/test/widgets/scroll_view_test.dart b/packages/flutter/test/widgets/scroll_view_test.dart index 32e501c5d9..54c841077f 100644 --- a/packages/flutter/test/widgets/scroll_view_test.dart +++ b/packages/flutter/test/widgets/scroll_view_test.dart @@ -19,9 +19,7 @@ void main() { }, child: new Container( height: 200.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), child: new Text(state), ), ); @@ -51,9 +49,7 @@ void main() { children: kStates.take(n).map((String state) { return new Container( height: 200.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), child: new Text(state), ); }).toList() @@ -87,9 +83,7 @@ void main() { }, child: new Container( height: 200.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), child: new Text(state), ), ); diff --git a/packages/flutter/test/widgets/single_child_scroll_view_test.dart b/packages/flutter/test/widgets/single_child_scroll_view_test.dart index cfb42cd200..716f635a76 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -36,9 +36,7 @@ void main() { await tester.pumpWidget(new SingleChildScrollView( child: new Container( height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), )); @@ -56,9 +54,7 @@ void main() { await tester.pumpWidget(new SingleChildScrollView( child: new Container( height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), )); @@ -66,9 +62,7 @@ void main() { controller: controller, child: new Container( height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), )); @@ -84,9 +78,7 @@ void main() { primary: true, child: new Container( height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), ), )); @@ -107,9 +99,7 @@ void main() { return new SingleChildScrollView( child: new Container( height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), ); }, @@ -126,9 +116,7 @@ void main() { controller: controller, child: new Container( height: 2000.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), ); }, diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index ad59724c71..581f157d8d 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -200,7 +200,7 @@ void main() { final Key key = const Key('container'); final BoxDecoration kBoxDecoration = const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) + color: const Color(0xFF00FF00), ); await tester.pumpWidget( diff --git a/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart b/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart index 0be4eb5130..858cc21fd2 100644 --- a/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart +++ b/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart @@ -28,38 +28,38 @@ class FooState extends State { scrollController.animateTo(200.0, duration: const Duration(milliseconds: 500), curve: Curves.linear); }, child: const DecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0)), + decoration: const BoxDecoration(color: const Color(0)), child: const SizedBox( height: 200.0, ), ) ), const DecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0)), + decoration: const BoxDecoration(color: const Color(0)), child: const SizedBox( height: 200.0, ), ), const DecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0)), + decoration: const BoxDecoration(color: const Color(0)), child: const SizedBox( height: 200.0, ), ), const DecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0)), + decoration: const BoxDecoration(color: const Color(0)), child: const SizedBox( height: 200.0, ), ), const DecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0)), + decoration: const BoxDecoration(color: const Color(0)), child: const SizedBox( height: 200.0, ), ), const DecoratedBox( - decoration: const BoxDecoration(backgroundColor: const Color(0)), + decoration: const BoxDecoration(color: const Color(0)), child: const SizedBox( height: 200.0, ), diff --git a/packages/flutter/test/widgets/test_widgets.dart b/packages/flutter/test/widgets/test_widgets.dart index d65e08ed30..fd2498e651 100644 --- a/packages/flutter/test/widgets/test_widgets.dart +++ b/packages/flutter/test/widgets/test_widgets.dart @@ -7,15 +7,15 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; final BoxDecoration kBoxDecorationA = const BoxDecoration( - backgroundColor: const Color(0xFFFF0000) + color: const Color(0xFFFF0000), ); final BoxDecoration kBoxDecorationB = const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) + color: const Color(0xFF00FF00), ); final BoxDecoration kBoxDecorationC = const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) + color: const Color(0xFF0000FF), ); class TestBuildCounter extends StatelessWidget { diff --git a/packages/flutter/test/widgets/transform_test.dart b/packages/flutter/test/widgets/transform_test.dart index 407891a625..eb8c7cbdd7 100644 --- a/packages/flutter/test/widgets/transform_test.dart +++ b/packages/flutter/test/widgets/transform_test.dart @@ -19,9 +19,7 @@ void main() { child: new Container( width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), ), ), new Positioned( @@ -38,9 +36,7 @@ void main() { didReceiveTap = true; }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FFFF), - ), + color: const Color(0xFF00FFFF), ), ), ), @@ -68,9 +64,7 @@ void main() { child: new Container( width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), ), ), new Positioned( @@ -87,9 +81,7 @@ void main() { didReceiveTap = true; }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FFFF), - ), + color: const Color(0xFF00FFFF), ), ), ), @@ -116,9 +108,7 @@ void main() { child: new Container( width: 100.0, height: 100.0, - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF), - ), + color: const Color(0xFF0000FF), ), ), new Positioned( @@ -136,9 +126,7 @@ void main() { didReceiveTap = true; }, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FFFF), - ), + color: const Color(0xFF00FFFF), ), ), ), @@ -166,9 +154,7 @@ void main() { child: new Opacity( opacity: 0.9, child: new Container( - decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00), - ), + color: const Color(0xFF00FF00), ), ), ), diff --git a/packages/flutter/test/widgets/transitions_test.dart b/packages/flutter/test/widgets/transitions_test.dart index d457759250..e1e410df05 100644 --- a/packages/flutter/test/widgets/transitions_test.dart +++ b/packages/flutter/test/widgets/transitions_test.dart @@ -18,7 +18,7 @@ void main() { group('DecoratedBoxTransition test', () { final DecorationTween decorationTween = new DecorationTween( begin: new BoxDecoration( - backgroundColor: const Color(0xFFFFFFFF), + color: const Color(0xFFFFFFFF), border: new Border.all( color: const Color(0xFF000000), style: BorderStyle.solid, @@ -33,7 +33,7 @@ void main() { )], ), end: new BoxDecoration( - backgroundColor: const Color(0xFF000000), + color: const Color(0xFF000000), border: new Border.all( color: const Color(0xFF202020), style: BorderStyle.solid, @@ -65,7 +65,7 @@ void main() { tester.renderObject(find.byType(DecoratedBox)); BoxDecoration actualDecoration = actualBox.decoration; - expect(actualDecoration.backgroundColor, const Color(0xFFFFFFFF)); + expect(actualDecoration.color, const Color(0xFFFFFFFF)); expect(actualDecoration.boxShadow[0].blurRadius, 10.0); expect(actualDecoration.boxShadow[0].spreadRadius, 4.0); expect(actualDecoration.boxShadow[0].color, const Color(0x66000000)); @@ -76,7 +76,7 @@ void main() { actualBox = tester.renderObject(find.byType(DecoratedBox)); actualDecoration = actualBox.decoration; - expect(actualDecoration.backgroundColor, const Color(0xFF7F7F7F)); + expect(actualDecoration.color, const Color(0xFF7F7F7F)); expect(actualDecoration.border.left.width, 2.5); expect(actualDecoration.border.left.style, BorderStyle.solid); expect(actualDecoration.border.left.color, const Color(0xFF101010)); @@ -93,7 +93,7 @@ void main() { actualBox = tester.renderObject(find.byType(DecoratedBox)); actualDecoration = actualBox.decoration; - expect(actualDecoration.backgroundColor, const Color(0xFF000000)); + expect(actualDecoration.color, const Color(0xFF000000)); expect(actualDecoration.boxShadow, null); } ); @@ -117,7 +117,7 @@ void main() { tester.renderObject(find.byType(DecoratedBox)); BoxDecoration actualDecoration = actualBox.decoration; - expect(actualDecoration.backgroundColor, const Color(0xFFFFFFFF)); + expect(actualDecoration.color, const Color(0xFFFFFFFF)); expect(actualDecoration.boxShadow[0].blurRadius, 10.0); expect(actualDecoration.boxShadow[0].spreadRadius, 4.0); expect(actualDecoration.boxShadow[0].color, const Color(0x66000000)); @@ -130,7 +130,7 @@ void main() { // Same as the test above but the values should be much closer to the // tween's end values given the easeOut curve. - expect(actualDecoration.backgroundColor, const Color(0xFF505050)); + expect(actualDecoration.color, const Color(0xFF505050)); expect(actualDecoration.border.left.width, closeTo(1.9, 0.1)); expect(actualDecoration.border.left.style, BorderStyle.solid); expect(actualDecoration.border.left.color, const Color(0xFF151515)); diff --git a/packages/flutter_markdown/lib/src/style_sheet.dart b/packages/flutter_markdown/lib/src/style_sheet.dart index f8c0f38733..02851ce4fd 100644 --- a/packages/flutter_markdown/lib/src/style_sheet.dart +++ b/packages/flutter_markdown/lib/src/style_sheet.dart @@ -66,12 +66,12 @@ class MarkdownStyleSheet { listIndent: 32.0, blockquotePadding: 8.0, blockquoteDecoration: new BoxDecoration( - backgroundColor: Colors.blue.shade100, + color: Colors.blue.shade100, borderRadius: new BorderRadius.circular(2.0) ), codeblockPadding: 8.0, codeblockDecoration: new BoxDecoration( - backgroundColor: Colors.grey.shade100, + color: Colors.grey.shade100, borderRadius: new BorderRadius.circular(2.0) ) ); @@ -103,12 +103,12 @@ class MarkdownStyleSheet { listIndent: 32.0, blockquotePadding: 8.0, blockquoteDecoration: new BoxDecoration( - backgroundColor: Colors.blue.shade100, + color: Colors.blue.shade100, borderRadius: new BorderRadius.circular(2.0) ), codeblockPadding: 8.0, codeblockDecoration: new BoxDecoration( - backgroundColor: Colors.grey.shade100, + color: Colors.grey.shade100, borderRadius: new BorderRadius.circular(2.0) ) );