performLayout method

  1. @override
void performLayout()
override

Calculates the size of this render box and populates size.

Creates text spans from _parseText, measures them within the available width, and constrains the result to fit within the parent's constraints.

Implementation

@override
void performLayout() {
  _textPainter.text = TextSpan(
    style: normalStyle.style,
    children: _parseText,
  );

  final maxWidth = constraints.hasBoundedWidth ? constraints.maxWidth : double.infinity;

  _textPainter.layout(maxWidth: maxWidth);

  size = constraints.constrain(Size(maxWidth.isFinite ? maxWidth : _textPainter.width, _textPainter.height));
}