From 6bef1736c1f5d31b8da9118a285b6dad393155a8 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Sun, 6 Mar 2016 12:28:28 -0800 Subject: [PATCH] Remove the second argument to MultiChildLayoutDelegate.performLayout() Fixes https://github.com/flutter/flutter/issues/2403 I have an e-mail ready to send to flutter-dev about this. --- packages/flutter/lib/src/material/scaffold.dart | 5 ++--- .../flutter/lib/src/rendering/custom_layout.dart | 15 +++++++-------- .../widget/custom_multi_child_layout_test.dart | 9 ++------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index e1787f29cb..f606b41fe7 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -39,9 +39,8 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { final EdgeDims padding; - void performLayout(Size size, BoxConstraints constraints) { - - BoxConstraints looseConstraints = constraints.loosen(); + void performLayout(Size size) { + BoxConstraints looseConstraints = new BoxConstraints.loose(size); // This part of the layout has the same effect as putting the toolbar and // body in a column and making the body flexible. What's different is that diff --git a/packages/flutter/lib/src/rendering/custom_layout.dart b/packages/flutter/lib/src/rendering/custom_layout.dart index 8bf35ee157..f6ae9349dc 100644 --- a/packages/flutter/lib/src/rendering/custom_layout.dart +++ b/packages/flutter/lib/src/rendering/custom_layout.dart @@ -103,7 +103,7 @@ abstract class MultiChildLayoutDelegate { return '${childParentData.id}: $child'; } - void _callPerformLayout(Size size, BoxConstraints constraints, RenderBox firstChild) { + void _callPerformLayout(Size size, RenderBox firstChild) { // A particular layout delegate could be called reentrantly, e.g. if it used // by both a parent and a child. So, we must restore the _idToChild map when // we return. @@ -138,7 +138,7 @@ abstract class MultiChildLayoutDelegate { }); child = childParentData.nextSibling; } - performLayout(size, constraints); + performLayout(size); assert(() { if (_debugChildrenNeedingLayout.isNotEmpty) { if (_debugChildrenNeedingLayout.length > 1) { @@ -176,11 +176,10 @@ abstract class MultiChildLayoutDelegate { /// possible given the constraints. Size getSize(BoxConstraints constraints) => constraints.biggest; - /// Override this method to lay out and position all children given - /// this widget's size and the specified constraints. This method - /// must call [layoutChild] for each child. It should also specify - /// the final position of each child with [positionChild]. - void performLayout(Size size, BoxConstraints constraints); + /// Override this method to lay out and position all children given this + /// widget's size. This method must call [layoutChild] for each child. It + /// should also specify the final position of each child with [positionChild]. + void performLayout(Size size); /// Override this method to return true when the children need to be /// laid out. This should compare the fields of the current delegate @@ -257,7 +256,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox } void performLayout() { - delegate._callPerformLayout(size, constraints, firstChild); + delegate._callPerformLayout(size, firstChild); } void paint(PaintingContext context, Offset offset) { diff --git a/packages/flutter/test/widget/custom_multi_child_layout_test.dart b/packages/flutter/test/widget/custom_multi_child_layout_test.dart index 6145a77cce..900ec4d463 100644 --- a/packages/flutter/test/widget/custom_multi_child_layout_test.dart +++ b/packages/flutter/test/widget/custom_multi_child_layout_test.dart @@ -17,16 +17,15 @@ class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate { } Size performLayoutSize; - BoxConstraints performLayoutConstraints; Size performLayoutSize0; Size performLayoutSize1; bool performLayoutIsChild; - void performLayout(Size size, BoxConstraints constraints) { + void performLayout(Size size) { assert(!RenderObject.debugCheckingIntrinsics); expect(() { performLayoutSize = size; - performLayoutConstraints = constraints; + BoxConstraints constraints = new BoxConstraints.loose(size); performLayoutSize0 = layoutChild(0, constraints); performLayoutSize1 = layoutChild(1, constraints); performLayoutIsChild = isChild('fred'); @@ -68,10 +67,6 @@ void main() { expect(delegate.performLayoutSize.width, 200.0); expect(delegate.performLayoutSize.height, 300.0); - expect(delegate.performLayoutConstraints.minWidth, 0.0); - expect(delegate.performLayoutConstraints.maxWidth, 800.0); - expect(delegate.performLayoutConstraints.minHeight, 0.0); - expect(delegate.performLayoutConstraints.maxHeight, 600.0); expect(delegate.performLayoutSize0.width, 150.0); expect(delegate.performLayoutSize0.height, 100.0); expect(delegate.performLayoutSize1.width, 100.0);