performBoxLayout method

  1. @override
void performBoxLayout(
  1. BoxConstraints constraints
)
override

Perform layout with typed box constraints

Subclasses override this instead of performLayout. The default implementation sizes to the maxima, treating an unbounded axis as the corresponding lower bound.

Implementation

@override
void performBoxLayout(BoxConstraints constraints) {
  // Fall back to minWidth when both the explicit width and the parent's
  // maxWidth are unspecified so we still produce a definite size.
  final w = _explicitWidth ?? constraints.maxWidth ?? constraints.minWidth;
  final constrainedWidth = constraints.constrainWidth(w);
  final layout = _ensureVisualLayout(constrainedWidth);
  final desiredHeight = _maxHeightLines == null
      ? _heightLines
      : layout.lines.length.clamp(_heightLines, _maxHeightLines!);
  size = Size(constrainedWidth, constraints.constrainHeight(desiredHeight));
  _layoutMetrics?.publish(size);
}