text property

InlineSpan? text

The (potentially styled) text to paint.

After this is set, you must call layout before the next call to paint. This and textDirection must be non-null before you call layout.

The InlineSpan this provides is in the form of a tree that may contain multiple instances of TextSpans and WidgetSpans. To obtain a plain text representation of the contents of this TextPainter, use plainText.

Implementation

InlineSpan? get text => _text;
void text=(InlineSpan? value)

Implementation

set text(InlineSpan? value) {
  assert(value == null || value.debugAssertIsValid());
  if (_text == value) {
    return;
  }
  if (_text?.style != value?.style) {
    _layoutTemplate?.dispose();
    _layoutTemplate = null;
  }

  final RenderComparison comparison = value == null
    ? RenderComparison.layout
    : _text?.compareTo(value) ?? RenderComparison.layout;

  _text = value;
  _cachedPlainText = null;

  if (comparison.index >= RenderComparison.layout.index) {
    markNeedsLayout();
  } else if (comparison.index >= RenderComparison.paint.index) {
    // Don't invalid the _layoutCache just yet. It still contains valid layout
    // information.
    _rebuildParagraphForPaint = true;
  }
  // Neither relayout or repaint is needed.
}