Include BoxDecoration description in Container toString
Have BoxDecoration default to one-line dumps Style nits in a rendering example
This commit is contained in:
parent
abb17ea93f
commit
8c44c38299
@ -8,16 +8,19 @@ import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
var coloredBox = new RenderDecoratedBox(
|
||||
RenderBox coloredBox = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
gradient: new RadialGradient(
|
||||
center: Point.origin, radius: 500.0,
|
||||
colors: <Color>[Colors.yellow[500], Colors.blue[500]]),
|
||||
boxShadow: elevationToShadow[8])
|
||||
colors: <Color>[Colors.yellow[500], Colors.blue[500]]
|
||||
),
|
||||
boxShadow: elevationToShadow[8]
|
||||
)
|
||||
);
|
||||
var paddedBox = new RenderPadding(
|
||||
RenderBox paddedBox = new RenderPadding(
|
||||
padding: const EdgeDims.all(50.0),
|
||||
child: coloredBox);
|
||||
child: coloredBox
|
||||
);
|
||||
new RenderingFlutterBinding(root: new RenderDecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
backgroundColor: const Color(0xFFFFFFFF)
|
||||
|
@ -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 = '']) {
|
||||
List<String> result = <String>[];
|
||||
if (backgroundColor != null)
|
||||
@ -803,6 +806,8 @@ class BoxDecoration extends Decoration {
|
||||
result.add('${prefix}gradient: $gradient');
|
||||
if (shape != BoxShape.rectangle)
|
||||
result.add('${prefix}shape: $shape');
|
||||
if (prefix == '')
|
||||
return '$runtimeType(${result.join(', ')})';
|
||||
if (result.isEmpty)
|
||||
return '$prefix<no decorations specified>';
|
||||
return result.join('\n');
|
||||
|
@ -908,9 +908,9 @@ class Container extends StatelessComponent {
|
||||
if (constraints != null)
|
||||
description.add('$constraints');
|
||||
if (decoration != null)
|
||||
description.add('has background');
|
||||
description.add('bg: $decoration');
|
||||
if (foregroundDecoration != null)
|
||||
description.add('has foreground');
|
||||
description.add('fg: $foregroundDecoration');
|
||||
if (margin != null)
|
||||
description.add('margin: $margin');
|
||||
if (padding != null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user