buildTextSpan method

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

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,
}) {
  final List<TextSpan> spanChildren = [];

  for (final TextDelta delta in deltas) {
    spanChildren.add(
      TextSpan(
        text: delta.char,
        style: delta.metadata?.style ??
            RichTextEditorController.defaultMetadata.style,
      ),
    );
  }

  final TextSpan textSpan = TextSpan(
    style: metadata?.styleWithoutFontFeatures ?? style,
    children: spanChildren,
  );
  return textSpan;
}