buildTextSpan method

  1. @override
TextSpan buildTextSpan({
  1. required BuildContext context,
  2. TextStyle? style,
  3. required bool withComposing,
})
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(
    {required BuildContext context,
    TextStyle? style,
    required bool withComposing}) {
  if (!value.isComposingRangeValid || !withComposing) {
    return TextSpan(
        style: style,
        children: _utils.setEmojiTextStyle(text,
            emojiStyle: emojiStyle, parentStyle: style));
  }
  final composingStyle =
      style?.merge(const TextStyle(decoration: TextDecoration.underline)) ??
          const TextStyle(decoration: TextDecoration.underline);
  return TextSpan(
    style: style,
    children: <TextSpan>[
      TextSpan(
          children: _utils.setEmojiTextStyle(
              value.composing.textBefore(value.text),
              emojiStyle: emojiStyle)),
      TextSpan(
        style: composingStyle,
        children: _utils.setEmojiTextStyle(
            value.composing.textInside(value.text),
            emojiStyle: emojiStyle,
            parentStyle: composingStyle),
      ),
      TextSpan(
          children: _utils.setEmojiTextStyle(
              value.composing.textAfter(value.text),
              emojiStyle: emojiStyle)),
    ],
  );
}