onEmojiBackPressed method
dynamic
onEmojiBackPressed()
Implementation
onEmojiBackPressed() {
var text = nameController.text;
var cursorPosition = nameController.selection.base.offset;
// If cursor is not set, then place it at the end of the textfield
if (cursorPosition < 0) {
nameController.selection = TextSelection(
baseOffset: nameController.text.length,
extentOffset: nameController.text.length,
);
cursorPosition = nameController.selection.base.offset;
}
if (cursorPosition >= 0) {
final selection = nameController.value.selection;
final newTextBeforeCursor =
selection.textBefore(text).characters.skipLast(1).toString();
LogMessage.d("newTextBeforeCursor", newTextBeforeCursor);
nameController
..text = newTextBeforeCursor + selection.textAfter(text)
..selection = TextSelection.fromPosition(
TextPosition(offset: newTextBeforeCursor.length));
}
count((25 - nameController.text.characters.length));
}