diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index d12ec23d25..6332188ac5 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -841,8 +841,8 @@ class BoxParentData extends ParentData { String toString() => 'offset=$offset'; } -/// Abstract ParentData subclass for RenderBox subclasses that want the -/// ContainerRenderObjectMixin. +/// Abstract [ParentData] subclass for [RenderBox] subclasses that want the +/// [ContainerRenderObjectMixin]. /// /// This is a convenience class that mixes in the relevant classes with /// the relevant type arguments. diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index 76afea12c7..db80b276f7 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -2984,6 +2984,11 @@ mixin RenderObjectWithChildMixin on RenderObject } /// Parent data to support a doubly-linked list of children. +/// +/// The children can be traversed using [nextSibling] or [previousSibling], +/// which can be called on the parent data of the render objects +/// obtained via [ContainerRenderObjectMixin.firstChild] or +/// [ContainerRenderObjectMixin.lastChild]. mixin ContainerParentDataMixin on ParentData { /// The previous sibling in the parent's child list. ChildType previousSibling; @@ -3003,6 +3008,20 @@ mixin ContainerParentDataMixin on ParentData { /// /// Provides a child model for a render object subclass that has a doubly-linked /// list of children. +/// +/// The [ChildType] specifies the type of the children (extending [RenderObject]), +/// e.g. [RenderBox]. +/// +/// [ParentDataType] stores parent container data on its child render objects. +/// It must extend [ContainerParentDataMixin], which provides the interface +/// for visiting children. This data is populated by +/// [RenderObject.setupParentData] implemented by the class using this mixin. +/// +/// When using [RenderBox] as the child type, you will usually want to make use of +/// [RenderBoxContainerDefaultsMixin] and extend [ContainerBoxParentData] for the +/// parent data. +/// +/// Moreover, this is a required mixin for render objects returned to [MultiChildRenderObjectWidget]. mixin ContainerRenderObjectMixin> on RenderObject { bool _debugUltimatePreviousSiblingOf(ChildType child, { ChildType equals }) { ParentDataType childParentData = child.parentData as ParentDataType; diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index b59e1c5aa3..3bfd59382f 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -1799,10 +1799,20 @@ abstract class SingleChildRenderObjectWidget extends RenderObjectWidget { SingleChildRenderObjectElement createElement() => SingleChildRenderObjectElement(this); } -/// A superclass for RenderObjectWidgets that configure RenderObject subclasses +/// A superclass for [RenderObjectWidget]s that configure [RenderObject] subclasses /// that have a single list of children. (This superclass only provides the /// storage for that child list, it doesn't actually provide the updating /// logic.) +/// +/// This will return a [RenderObject] mixing in [ContainerRenderObjectMixin], +/// which provides the necessary functionality to visit the children of the +/// container render object (the render object belonging to the [children] widgets). +/// Typically, this is a [RenderBox] with [RenderBoxContainerDefaultsMixin]. +/// +/// See also: +/// +/// * [Stack], which uses [MultiChildRenderObjectWidget]. +/// * [RenderStack], for an example implementation of the associated render object. abstract class MultiChildRenderObjectWidget extends RenderObjectWidget { /// Initializes fields for subclasses. ///