material_tag_editor icon indicating copy to clipboard operation
material_tag_editor copied to clipboard

Figure out a way to remove tag with the backspace keyboard key

Open panuavakul opened this issue 5 years ago • 3 comments

If anyone has any idea please let me know.

panuavakul avatar Nov 17 '20 02:11 panuavakul

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( ... ),
}

bungabear avatar Aug 27 '21 08:08 bungabear

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

LostInDarkMath avatar Dec 26 '21 11:12 LostInDarkMath

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 😢

panuavakul avatar Feb 02 '22 10:02 panuavakul