replaceLastMentionWithText method

void replaceLastMentionWithText(
  1. String text
)

Makes the last mention a plain text.

Implementation

void replaceLastMentionWithText(String text) {
  final start = lastMention.value?.locationStart;
  final end = lastMention.value?.locationEnd;

  if (start != null && end != null) {
    final newText = this.text.replaceRange(
          start,
          end,
          text,
        );

    value = value.copyWith(
      text: newText,
      selection: TextSelection.collapsed(offset: start + text.length),
      composing: TextRange.empty,
    );
  }
}