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
@override
TextSpan buildTextSpan({
BuildContext? context,
TextStyle? style,
bool? withComposing,
}) {
final regExp = this.regExp ?? detectionRegExp()!;
final baseStyle = style ?? const TextStyle();
final detectedStyle = this.detectedStyle ??
baseStyle.copyWith(
color: Colors.blue,
);
final detections = text.toDetections(
textStyle: baseStyle,
detectedStyle: detectedStyle,
detectionRegExp: regExp,
);
final composer = Composer(
selection: value.selection.start,
sourceText: value.text,
detectedStyle: detectedStyle,
detections: detections,
composing: value.composing,
);
if (detections.isEmpty) {
/// use same method as default textField to show composing underline
return super.buildTextSpan(
context: context!,
style: baseStyle,
withComposing: withComposing ?? false,
);
}
return composer.getComposedTextSpan();
}