addHandler method
- KeyEventCallback handler
Register a listener that is called every time a hardware key event occurs.
All registered handlers will be invoked in order regardless of their return value. The return value indicates whether Flutter "handles" the event. If any handler returns true, the event will not be propagated to other native components in the add-to-app scenario.
If an object added a handler, it must remove the handler before it is disposed.
If used during event dispatching, the addition will not take effect until after the dispatching.
See also:
- removeHandler, which removes the handler.
Implementation
void addHandler(KeyEventCallback handler) {
if (_duringDispatch) {
_modifiedHandlers ??= <KeyEventCallback>[..._handlers];
_modifiedHandlers!.add(handler);
} else {
_handlers.add(handler);
}
}