Commit 1a5639d3 authored by Adam Barth's avatar Adam Barth

Merge pull request #707 from abarth/tiny_flex

RenderFlex shouldn't assert when its out of space
parents ab74b178 7e474f6d
......@@ -466,14 +466,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
case FlexDirection.horizontal:
size = constraints.constrain(new Size(_overflow, crossSize));
crossSize = size.height;
assert(size.width >= _overflow);
remainingSpace = size.width - _overflow;
remainingSpace = math.max(0.0, size.width - _overflow);
break;
case FlexDirection.vertical:
size = constraints.constrain(new Size(crossSize, _overflow));
crossSize = size.width;
assert(size.height >= _overflow);
remainingSpace = size.height - _overflow;
remainingSpace = math.max(0.0, size.height - _overflow);
break;
}
_overflow = 0.0;
......
......@@ -108,4 +108,46 @@ void main() {
expect(renderBox.size.height, equals(250.0));
});
});
test('Can layout at zero size', () {
final Key childKey = new Key('childKey');
testWidgets((WidgetTester tester) {
tester.pumpWidget(new Center(
child: new Container(
width: 0.0,
height: 0.0,
child: new Column([
new Container(
key: childKey,
width: 100.0,
height: 100.0
)], justifyContent: FlexJustifyContent.collapse
)
)
));
RenderBox renderBox = tester.findElementByKey(childKey).renderObject;
expect(renderBox.size.width, equals(0.0));
expect(renderBox.size.height, equals(100.0));
tester.pumpWidget(new Center(
child: new Container(
width: 0.0,
height: 0.0,
child: new Row([
new Container(
key: childKey,
width: 100.0,
height: 100.0
)], justifyContent: FlexJustifyContent.collapse
)
)
));
renderBox = tester.findElementByKey(childKey).renderObject;
expect(renderBox.size.width, equals(100.0));
expect(renderBox.size.height, equals(0.0));
});
});
}
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