Document reasoning for why CustomMultiChildLayout size can't depend on children and how to do it (#47797)

This commit is contained in:
creativecreatorormaybenot 2020-01-08 02:48:01 +00:00 committed by Flutter GitHub Bot
parent a1bf03f87a
commit de2514c0e2
2 changed files with 10 additions and 2 deletions

View File

@ -29,7 +29,15 @@ class MultiChildLayoutParentData extends ContainerBoxParentData<RenderBox> {
/// given the previous instance. /// given the previous instance.
/// ///
/// Override [getSize] to control the overall size of the layout. The size of /// Override [getSize] to control the overall size of the layout. The size of
/// the layout cannot depend on layout properties of the children. /// the layout cannot depend on layout properties of the children. This was
/// a design decision to simplify the delegate implementations: This way,
/// the delegate implementations do not have to also handle various intrinsic
/// sizing functions if the parent's size depended on the children.
/// If you want to build a custom layout where you define the size of that widget
/// based on its children, then you will have to create a custom render object.
/// See [MultiChildRenderObjectWidget] with [ContainerRenderObjectMixin] and
/// [RenderBoxContainerDefaultsMixin] to get started or [RenderStack] for an
/// example implementation.
/// ///
/// Override [performLayout] to size and position the children. An /// Override [performLayout] to size and position the children. An
/// implementation of [performLayout] must call [layoutChild] exactly once for /// implementation of [performLayout] must call [layoutChild] exactly once for

View File

@ -1955,7 +1955,7 @@ class LayoutId extends ParentDataWidget<CustomMultiChildLayout> {
/// the children. /// the children.
/// ///
/// [CustomMultiChildLayout] is appropriate when there are complex relationships /// [CustomMultiChildLayout] is appropriate when there are complex relationships
/// between the size and positioning of a multiple widgets. To control the /// between the size and positioning of multiple widgets. To control the
/// layout of a single child, [CustomSingleChildLayout] is more appropriate. For /// layout of a single child, [CustomSingleChildLayout] is more appropriate. For
/// simple cases, such as aligning a widget to one or another edge, the [Stack] /// simple cases, such as aligning a widget to one or another edge, the [Stack]
/// widget is more appropriate. /// widget is more appropriate.