SingleChildLayoutDelegate class

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 object will listen to this value and relayout whenever the animation ticks, avoiding both the build phase of the pipeline.

See also:

Constructors

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

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

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. [...]
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). [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited