material_tag_editor
material_tag_editor copied to clipboard
Figure out a way to remove tag with the backspace keyboard key
If anyone has any idea please let me know.
Wrap TagEditor with RawKeyboardListener. Then, you can get backspace key event while TextField is empty.
RawKeyboardListener(
focusNode: FocusNode(),
onKey: (event){
if(event.runtimeType.toString() == 'RawKeyDownEvent'){
if (event.logicalKey == LogicalKeyboardKey.backspace) {
if(pop != null){
setState(() {
tagList.remove(tagList.last);
});
}
}
}
},
child: TagEditor( ... ),
}
Unfortunately this is impossible for soft keyboards: https://github.com/flutter/flutter/issues/86560 Details: https://medium.com/super-declarative/why-you-cant-detect-a-delete-action-in-an-empty-flutter-text-field-3cf53e47b631
I remember that I was playing around with the whitespace idea. While it was somewhat working, it ended up being complicated and can be buggy if user play around with the TextField so I didn't push it to develop. Hopefully, there are someway we could easily implement it 😢