Docs: provide Guidance for MultiChildRenderObjectWidget implementations (#49994)
provide Guidance for MultiChildRenderObjectWidget implementations
This commit is contained in:
parent
e4014a55c8
commit
cc7b886491
@ -841,8 +841,8 @@ class BoxParentData extends ParentData {
|
|||||||
String toString() => 'offset=$offset';
|
String toString() => 'offset=$offset';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Abstract ParentData subclass for RenderBox subclasses that want the
|
/// Abstract [ParentData] subclass for [RenderBox] subclasses that want the
|
||||||
/// ContainerRenderObjectMixin.
|
/// [ContainerRenderObjectMixin].
|
||||||
///
|
///
|
||||||
/// This is a convenience class that mixes in the relevant classes with
|
/// This is a convenience class that mixes in the relevant classes with
|
||||||
/// the relevant type arguments.
|
/// the relevant type arguments.
|
||||||
|
@ -2984,6 +2984,11 @@ mixin RenderObjectWithChildMixin<ChildType extends RenderObject> on RenderObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parent data to support a doubly-linked list of children.
|
/// 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<ChildType extends RenderObject> on ParentData {
|
mixin ContainerParentDataMixin<ChildType extends RenderObject> on ParentData {
|
||||||
/// The previous sibling in the parent's child list.
|
/// The previous sibling in the parent's child list.
|
||||||
ChildType previousSibling;
|
ChildType previousSibling;
|
||||||
@ -3003,6 +3008,20 @@ mixin ContainerParentDataMixin<ChildType extends RenderObject> on ParentData {
|
|||||||
///
|
///
|
||||||
/// Provides a child model for a render object subclass that has a doubly-linked
|
/// Provides a child model for a render object subclass that has a doubly-linked
|
||||||
/// list of children.
|
/// 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<ChildType extends RenderObject, ParentDataType extends ContainerParentDataMixin<ChildType>> on RenderObject {
|
mixin ContainerRenderObjectMixin<ChildType extends RenderObject, ParentDataType extends ContainerParentDataMixin<ChildType>> on RenderObject {
|
||||||
bool _debugUltimatePreviousSiblingOf(ChildType child, { ChildType equals }) {
|
bool _debugUltimatePreviousSiblingOf(ChildType child, { ChildType equals }) {
|
||||||
ParentDataType childParentData = child.parentData as ParentDataType;
|
ParentDataType childParentData = child.parentData as ParentDataType;
|
||||||
|
@ -1799,10 +1799,20 @@ abstract class SingleChildRenderObjectWidget extends RenderObjectWidget {
|
|||||||
SingleChildRenderObjectElement createElement() => SingleChildRenderObjectElement(this);
|
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
|
/// that have a single list of children. (This superclass only provides the
|
||||||
/// storage for that child list, it doesn't actually provide the updating
|
/// storage for that child list, it doesn't actually provide the updating
|
||||||
/// logic.)
|
/// 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 {
|
abstract class MultiChildRenderObjectWidget extends RenderObjectWidget {
|
||||||
/// Initializes fields for subclasses.
|
/// Initializes fields for subclasses.
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user