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:

Implementers

Constructors

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

Properties

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

Methods

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.
inherited
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.
inherited

Operators

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