buildTextSpan method

  1. @override
TextSpan buildTextSpan({
  1. required BuildContext context,
  2. TextStyle? style,
  3. required bool withComposing,
})
override

Builds TextSpan from current editing value.

By default makes text in composing range appear as underlined. Descendants can override this method to customize appearance of text.

Implementation

@override
TextSpan buildTextSpan({
  required BuildContext context,
  TextStyle? style,
  required bool withComposing,
}) {
  _style = style;

  if (_parser == null) {
    // Initialisation must not occur before the first call to this method.
    // The text style from the editable text is not available before then.
    _init();
  }

  return _textSpanNotifier.elements.isEmpty
      ? TextSpan(
          text: _textSpanNotifier.value.text,
          style: this.style ?? style,
        )
      : _textSpanNotifier.value;
}