performLayout method
Do the work of computing the layout for this render object.
Do not call this function directly: call layout instead. This function is called by layout when there is actually work to be done by this render object during layout. The layout constraints provided by your parent are available via the constraints getter.
If sizedByParent is true, then this function should not actually change the dimensions of this render object. Instead, that work should be done by performResize. If sizedByParent is false, then this function should both change the dimensions of this render object and instruct its children to layout.
In implementing this function, you must call layout on each of your children, passing true for parentUsesSize if your layout information is dependent on your child's layout information. Passing true for parentUsesSize ensures that this render object will undergo layout if the child undergoes layout. Otherwise, the child can change its layout information without informing this render object.
Some special RenderObject subclasses (such as the one used by OverlayPortal.overlayChildLayoutBuilder) call applyPaintTransform in their performLayout implementation. To ensure such RenderObjects get the up-to-date paint transform, RenderObject subclasses should typically update the paint transform (as reported by applyPaintTransform) in this method instead of paint.
Implementation
@override
void performLayout() {
final child = this.child;
if (child == null) {
size = constraints.smallest;
_offset = 0;
_drawn = 0;
_below = null;
_across = 0;
_lines = 0;
_moves = null;
_tops = null;
return;
}
final room = _asked(() => _room(constraints));
child.layout(room, parentUsesSize: true);
final exact = _exact(child);
final grown = exact == null ? _laidGrown(child) : null;
final (read, drop) = exact != null
? (exact.$1, exact.$2)
: grown != null
? (grown.height, grown.drop)
: _box(child.size.height, child.getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true));
// A LINE OF NOTHING BUT BOXES IS ONE NUMBER, ASKED OR LAID OUT. Before
// layout its height is worked out as CSS sizes it ([_boxesOnly]), in
// doubles; laid out it is read off the boxes Skia placed, in floats --
// the same line a millionth of a pixel apart. A box that measures what
// it holds before laying it out hands it the asked height, and a stock
// `Column` of five buttons, each an inline-block alone on its line, was
// handed 0.0000048 less than it came to: its debug overflow hatch
// covered the bottom tenth of a page. Where the two differ by that
// float's part of a pixel and no more, the line is the asked one.
final asked = _askedLaidOut(() => _boxesOnly(room.maxWidth))?.$1;
final tall = asked != null && (asked - read).abs() <= _floatNoise ? asked : read;
_offset = drop;
_drawn = exact?.$3 ?? 0;
_below = exact?.$4 ?? grown?.below;
size = constraints.constrain(Size(child.size.width, tall));
_across = _acrossFor(child, size.width);
_moves = grown?.moves;
_tops = grown?.tops;
_readLines(child, exact != null || grown != null);
}