How to listen to keyboard on screen Flutter?

后端 未结 5 984
栀梦
栀梦 2021-01-02 08:03

I am building a mobile app, I want to remove a widget when the keyboard appears on the screen, i.e when the input text field is on focus.

I have tried to use

5条回答
  •  抹茶落季
    2021-01-02 08:47

    A widget that calls a callback whenever the user presses or releases a key on a keyboard.

    A RawKeyboardListener is useful for listening to raw key events and hardware buttons that are represented as keys. Typically used by games and other apps that use keyboards for purposes other than text entry.

    For text entry, consider using a EditableText, which integrates with on-screen keyboards and input method editors (IMEs).

     const RawKeyboardListener({
    Key key,
    @required FocusNode focusNode,
    @required ValueChanged onKey,
    @required Widget child
    })
    

    Creates a widget that receives raw keyboard events.

    For text entry, consider using a EditableText, which integrates with on-screen keyboards and input method editors (IMEs).

    Implementation

    const RawKeyboardListener({
      Key key,
      @required this.focusNode,
      @required this.onKey,
      @required this.child,
    }) : assert(focusNode != null),
         assert(child != null),
         super(key: key);
    

提交回复
热议问题