updateBounds method

  1. @override
  2. @internal
void updateBounds()
override

Implementation

@override
@internal
void updateBounds() {
  _lines.clear();
  double? lineHeight;
  text.split(' ').forEach((word) {
    final possibleLine = _lines.isEmpty ? word : '${_lines.last} $word';
    lineHeight ??= textRenderer.measureTextHeight(possibleLine);

    final textWidth = textRenderer.measureTextWidth(possibleLine);
    if (textWidth <= _boxConfig.maxWidth - _boxConfig.margins.horizontal) {
      if (_lines.isNotEmpty) {
        _lines.last = possibleLine;
      } else {
        _lines.add(possibleLine);
      }
      _updateMaxWidth(textWidth);
    } else {
      _lines.add(word);
      _updateMaxWidth(textWidth);
    }
  });
  _totalLines = _lines.length;
  _lineHeight = lineHeight ?? 0.0;
  size = _recomputeSize();
}