Commit 3fb0df87 authored by Adam Barth's avatar Adam Barth

RenderCustomMultiChildLayoutBox shouldn't be sizedByParent

The getSize function from MultiChildLayoutDelegate might depend on information
other than the incomming constraints.

Fixes #2077
parent eba2d44f
...@@ -249,13 +249,8 @@ class RenderCustomMultiChildLayoutBox extends RenderBox ...@@ -249,13 +249,8 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
return _getSize(constraints).height; return _getSize(constraints).height;
} }
bool get sizedByParent => true;
void performResize() {
size = _getSize(constraints);
}
void performLayout() { void performLayout() {
size = _getSize(constraints);
delegate._callPerformLayout(size, firstChild); delegate._callPerformLayout(size, firstChild);
} }
......
...@@ -53,6 +53,19 @@ Widget buildFrame(MultiChildLayoutDelegate delegate) { ...@@ -53,6 +53,19 @@ Widget buildFrame(MultiChildLayoutDelegate delegate) {
); );
} }
class PreferredSizeDelegate extends MultiChildLayoutDelegate {
PreferredSizeDelegate({ this.preferredSize });
final Size preferredSize;
Size getSize(BoxConstraints constraints) => preferredSize;
void performLayout(Size size) { }
bool shouldRelayout(PreferredSizeDelegate oldDelegate) {
return preferredSize != oldDelegate.preferredSize;
}
}
void main() { void main() {
test('Control test for CustomMultiChildLayout', () { test('Control test for CustomMultiChildLayout', () {
...@@ -124,4 +137,30 @@ void main() { ...@@ -124,4 +137,30 @@ void main() {
}); });
}); });
test('Loose constraints', () {
testWidgets((WidgetTester tester) {
Key key = new UniqueKey();
tester.pumpWidget(new Center(
child: new CustomMultiChildLayout(
key: key,
delegate: new PreferredSizeDelegate(preferredSize: new Size(300.0, 200.0))
)
));
RenderBox box = tester.findElementByKey(key).renderObject;
expect(box.size.width, equals(300.0));
expect(box.size.height, equals(200.0));
tester.pumpWidget(new Center(
child: new CustomMultiChildLayout(
key: key,
delegate: new PreferredSizeDelegate(preferredSize: new Size(350.0, 250.0))
)
));
expect(box.size.width, equals(350.0));
expect(box.size.height, equals(250.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