onEmojiSelected method

dynamic onEmojiSelected(
  1. Emoji emoji
)

Implementation

onEmojiSelected(Emoji emoji) {
  if (groupName.text.characters.length < 25) {
    final controller = groupName;
    final text = controller.text;
    final selection = controller.selection;
    final cursorPosition = controller.selection.base.offset;

    if (cursorPosition < 0) {
      controller.text += emoji.emoji;
      // widget.onEmojiSelected?.call(category, emoji);
      return;
    }

    final newText =
        text.replaceRange(selection.start, selection.end, emoji.emoji);
    final emojiLength = emoji.emoji.length;
    controller
      ..text = newText
      ..selection = selection.copyWith(
        baseOffset: selection.start + emojiLength,
        extentOffset: selection.start + emojiLength,
      );
  }
  _count((25 - groupName.text.characters.length));
}