createPainter method

TextPainter createPainter(
  1. double width,
  2. FlexMeasureMode widthMode
)

Implementation

TextPainter createPainter(double width, FlexMeasureMode widthMode) {
  var unconstrainedWidth = widthMode == FlexMeasureMode.undefined || width < 0;
  var maxWidth = unconstrainedWidth ? double.infinity : width;
  if (span == null || dirty) {
    span = createSpan(useChild: true);
    dirty = false;
  }
  var painter = TextPainter(
    maxLines: _numberOfLines ?? kMaxLineCount,
    text: span,
    textDirection: TextDirection.ltr,
    textAlign: _textAlign,
    ellipsis: kEllipsis,
    textScaler: _generateTextScale(),
  );
  painter.setPlaceholderDimensions(_placeholderDimensions);
  painter.layout(maxWidth: maxWidth);
  return painter;
}