buildTextSpan method
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({TextStyle? style, required bool withComposing}) {
assert(!value.composing.isValid ||
!withComposing ||
value.isComposingRangeValid);
_replaceTabsWithSpaces();
// This is where the magic happens
if (_syntaxHighlighter != null && highlightingEnabled) {
// custom syntax highlighter is used.
return _buildSyntaxHighlightedTextSpan(style);
}
// No syntax highlighting is applied
if (!value.isComposingRangeValid || !withComposing) {
return TextSpan(style: style, text: text);
}
final TextStyle composingStyle = style!.merge(
const TextStyle(decoration: TextDecoration.underline),
);
return TextSpan(
style: style,
children: <TextSpan>[
TextSpan(text: value.composing.textBefore(value.text)),
TextSpan(
style: composingStyle,
text: value.composing.textInside(value.text),
),
TextSpan(
text: value.composing.textAfter(value.text),
),
],
);
}