Commit f757211f authored by Ian Hickson's avatar Ian Hickson

Merge pull request #1171 from Hixie/constraints

Merge Container's width, height, and constraints
parents c262842e 0379744c
...@@ -816,15 +816,20 @@ class Container extends StatelessComponent { ...@@ -816,15 +816,20 @@ class Container extends StatelessComponent {
Container({ Container({
Key key, Key key,
this.child, this.child,
this.constraints, BoxConstraints constraints,
this.decoration, this.decoration,
this.foregroundDecoration, this.foregroundDecoration,
this.margin, this.margin,
this.padding, this.padding,
this.transform, this.transform,
this.width, double width,
this.height double height
}) : super(key: key) { }) : constraints =
(width != null || height != null)
? constraints?.tighten(width: width, height: height)
?? new BoxConstraints.tightFor(width: width, height: height)
: constraints,
super(key: key) {
assert(margin == null || margin.isNonNegative); assert(margin == null || margin.isNonNegative);
assert(padding == null || padding.isNonNegative); assert(padding == null || padding.isNonNegative);
assert(decoration == null || decoration.debugAssertValid()); assert(decoration == null || decoration.debugAssertValid());
...@@ -853,12 +858,6 @@ class Container extends StatelessComponent { ...@@ -853,12 +858,6 @@ class Container extends StatelessComponent {
/// The transformation matrix to apply before painting the container. /// The transformation matrix to apply before painting the container.
final Matrix4 transform; 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;
EdgeDims get _paddingIncludingDecoration { EdgeDims get _paddingIncludingDecoration {
if (decoration == null || decoration.padding == null) if (decoration == null || decoration.padding == null)
return padding; return padding;
...@@ -871,7 +870,7 @@ class Container extends StatelessComponent { ...@@ -871,7 +870,7 @@ class Container extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget current = child; Widget current = child;
if (child == null && (width == null || height == null)) if (child == null && (constraints == null || !constraints.isTight))
current = new ConstrainedBox(constraints: const BoxConstraints.expand()); current = new ConstrainedBox(constraints: const BoxConstraints.expand());
EdgeDims effectivePadding = _paddingIncludingDecoration; EdgeDims effectivePadding = _paddingIncludingDecoration;
...@@ -889,14 +888,6 @@ class Container extends StatelessComponent { ...@@ -889,14 +888,6 @@ class Container extends StatelessComponent {
); );
} }
if (width != null || height != null) {
current = new SizedBox(
width: width,
height: height,
child: current
);
}
if (constraints != null) if (constraints != null)
current = new ConstrainedBox(constraints: constraints, child: current); current = new ConstrainedBox(constraints: constraints, child: current);
...@@ -923,10 +914,6 @@ class Container extends StatelessComponent { ...@@ -923,10 +914,6 @@ class Container extends StatelessComponent {
description.add('padding: $padding'); description.add('padding: $padding');
if (transform != null) if (transform != null)
description.add('has transform'); description.add('has transform');
if (width != null)
description.add('width: $width');
if (height != null)
description.add('height: $height');
} }
} }
......
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