Commit 8c44c382 authored by Ian Hickson's avatar Ian Hickson

Include BoxDecoration description in Container toString

Have BoxDecoration default to one-line dumps

Style nits in a rendering example
parent abb17ea9
...@@ -8,16 +8,19 @@ import 'package:flutter/rendering.dart'; ...@@ -8,16 +8,19 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
void main() { void main() {
var coloredBox = new RenderDecoratedBox( RenderBox coloredBox = new RenderDecoratedBox(
decoration: new BoxDecoration( decoration: new BoxDecoration(
gradient: new RadialGradient( gradient: new RadialGradient(
center: Point.origin, radius: 500.0, center: Point.origin, radius: 500.0,
colors: <Color>[Colors.yellow[500], Colors.blue[500]]), colors: <Color>[Colors.yellow[500], Colors.blue[500]]
boxShadow: elevationToShadow[8]) ),
boxShadow: elevationToShadow[8]
)
); );
var paddedBox = new RenderPadding( RenderBox paddedBox = new RenderPadding(
padding: const EdgeDims.all(50.0), padding: const EdgeDims.all(50.0),
child: coloredBox); child: coloredBox
);
new RenderingFlutterBinding(root: new RenderDecoratedBox( new RenderingFlutterBinding(root: new RenderDecoratedBox(
decoration: const BoxDecoration( decoration: const BoxDecoration(
backgroundColor: const Color(0xFFFFFFFF) backgroundColor: const Color(0xFFFFFFFF)
......
...@@ -787,6 +787,9 @@ class BoxDecoration extends Decoration { ...@@ -787,6 +787,9 @@ class BoxDecoration extends Decoration {
); );
} }
/// Stringifies the BoxDecoration. By default, the output will be on one line.
/// If the method is passed a non-empty string argument, then the output will
/// span multiple lines, each prefixed by that argument.
String toString([String prefix = '']) { String toString([String prefix = '']) {
List<String> result = <String>[]; List<String> result = <String>[];
if (backgroundColor != null) if (backgroundColor != null)
...@@ -803,6 +806,8 @@ class BoxDecoration extends Decoration { ...@@ -803,6 +806,8 @@ class BoxDecoration extends Decoration {
result.add('${prefix}gradient: $gradient'); result.add('${prefix}gradient: $gradient');
if (shape != BoxShape.rectangle) if (shape != BoxShape.rectangle)
result.add('${prefix}shape: $shape'); result.add('${prefix}shape: $shape');
if (prefix == '')
return '$runtimeType(${result.join(', ')})';
if (result.isEmpty) if (result.isEmpty)
return '$prefix<no decorations specified>'; return '$prefix<no decorations specified>';
return result.join('\n'); return result.join('\n');
......
...@@ -908,9 +908,9 @@ class Container extends StatelessComponent { ...@@ -908,9 +908,9 @@ class Container extends StatelessComponent {
if (constraints != null) if (constraints != null)
description.add('$constraints'); description.add('$constraints');
if (decoration != null) if (decoration != null)
description.add('has background'); description.add('bg: $decoration');
if (foregroundDecoration != null) if (foregroundDecoration != null)
description.add('has foreground'); description.add('fg: $foregroundDecoration');
if (margin != null) if (margin != null)
description.add('margin: $margin'); description.add('margin: $margin');
if (padding != null) if (padding != null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment