onEmojiSelected method
dynamic
onEmojiSelected(
- Emoji emoji
Implementation
onEmojiSelected(Emoji emoji) {
if (nameController.text.characters.length < 25) {
final controller = nameController;
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 - nameController.text.characters.length));
}