buildTextSpan method

  1. @override
TextSpan buildTextSpan()
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() {
  final detections = detector.getDetections(textEditingValue.text);
  final composer = Composer(
    selection: textEditingValue.selection.start,
    onDetectionTyped: widget.onDetectionTyped,
    sourceText: textEditingValue.text,
    decoratedStyle: widget.decoratedStyle,
    detections: detections,
    composing: textEditingValue.composing,
  );
  if (detections.isEmpty) {
    /// use same method as default textField to show composing underline
    return widget.controller.buildTextSpan(
      context: context,
      style: widget.style,
      withComposing: !widget.readOnly,
    );
  }
  return composer.getComposedTextSpan();
}