[development experience] button monitoring with fluent

Time:2020-1-9

In development, sometimes it is necessary to listen to key events, which is supported by flutter itself and does not need to be implemented in the lower platform native code.

Flutter monitors key events of mobile phone / remote control / keyboard

To realize the key monitoring, the fluent can be used directlyRawKeyboardListenerthisWidgetYou can:

RawKeyboardListener(
    Focusnode: focusnode(), // focus
    onKey: (RawKeyEvent event){
        // TODO: Key event here
    },
    Child: container(), // subcomponent
)

Focus processing

//Active focus acquisition
FocusScope.of(context).requestFocus(yourFocusNode);
//Get focus automatically
FocusScope.of(context).autofocus(yourFocusNode);

summary

I would like to thank you for your support.

Expanding reading: an attempt to develop the application of flutter TV

Recommended Today

Java security framework

The article is mainly divided into three parts1. The architecture and core components of spring security are as follows: (1) authentication; (2) authority interception; (3) database management; (4) authority caching; (5) custom decision making; and;2. To build and use the environment, the current popular spring boot is used to build the environment, and the actual […]