SingleChildLayoutDelegate class abstract

A delegate for computing the layout of a render object with a single child.

Used by CustomSingleChildLayout (in the widgets library) and RenderCustomSingleChildLayoutBox (in the rendering library).

When asked to layout, CustomSingleChildLayout first calls getSize with its incoming constraints to determine its size. It then calls getConstraintsForChild to determine the constraints to apply to the child. After the child completes its layout, RenderCustomSingleChildLayoutBox calls getPositionForChild to determine the child's position.

The shouldRelayout method is called when a new instance of the class is provided, to check if the new instance actually represents different information.

The most efficient way to trigger a relayout is to supply a relayout argument to the constructor of the SingleChildLayoutDelegate. The custom layout will listen to this value and relayout whenever the Listenable notifies its listeners, such as when an Animation ticks. This allows the custom layout to avoid the build phase of the pipeline.

See also:



SingleChildLayoutDelegate({Listenable? relayout})
Creates a layout delegate.


hashCode int
The hash code for this object.
runtimeType Type
A representation of the runtime type of the object.


getConstraintsForChild(BoxConstraints constraints) BoxConstraints
The constraints for the child given the incoming constraints.
getPositionForChild(Size size, Size childSize) Offset
The position where the child should be placed.
getSize(BoxConstraints constraints) Size
The size of this object given the incoming constraints.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
shouldRelayout(covariant SingleChildLayoutDelegate oldDelegate) bool
Called whenever a new instance of the custom layout delegate class is provided to the RenderCustomSingleChildLayoutBox object, or any time that a new CustomSingleChildLayout object is created with a new instance of the custom layout delegate class (which amounts to the same thing, because the latter is implemented in terms of the former).
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.