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() {
beforeLayout();
double lineHeight = _computeLineHeightPx();
// In a row-direction flex container, <br> should not add horizontal space
// nor increase cross size. Keep it zero-height in that scenario.
final parentStyle = renderStyle.getParentRenderStyle();
if (parentStyle != null && parentStyle.isSelfRenderFlexLayout()) {
if (CSSFlex.isHorizontalFlexDirection(parentStyle.flexDirection)) {
lineHeight = 0;
}
}
// BR contributes no intrinsic width; only vertical space of one line.
// Compute final border-box size from a content box of (0, lineHeight)
size = getBoxSize(Size(0, lineHeight));
// No overflow beyond its own box.
setMaxScrollableSize(Size(0, lineHeight));
// BR has no text baseline of its own.
setCssBaselines(first: null, last: null);
}