buildTextSpan method

TextSpan buildTextSpan()

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

TextSpan buildTextSpan() {
  if (widget.obscureText) {
    String text = _value.text;
    text = widget.obscuringCharacter * text.length;
    // Reveal the latest character in an obscured field only on mobile.
    if (defaultTargetPlatform == TargetPlatform.android ||
        defaultTargetPlatform == TargetPlatform.iOS ||
        defaultTargetPlatform == TargetPlatform.fuchsia) {
      final int? o =
          _obscureShowCharTicksPending > 0 ? _obscureLatestCharIndex : null;
      if (o != null && o >= 0 && o < text.length)
        text = text.replaceRange(o, o + 1, _value.text.substring(o, o + 1));
    }
    return TextSpan(style: widget.style, text: text);
  }
  // Read only mode should not paint text composing.
  return widget.controller.buildTextSpan(
    context: context,
    style: widget.style,
    withComposing: !widget.readOnly && _hasFocus,
  );
}