removeHandler method

void removeHandler(
  1. KeyEventCallback handler
)

Stop calling the given listener every time a hardware key event occurs.

The handler argument must be identical to the one used in addHandler. If multiple exist, the first one will be removed. If none is found, then this method is a no-op.

If used during event dispatching, the removal will not take effect until after the event has been dispatched.

Implementation

void removeHandler(KeyEventCallback handler) {
  if (_duringDispatch) {
    _modifiedHandlers ??= <KeyEventCallback>[..._handlers];
    _modifiedHandlers!.remove(handler);
  } else {
    _handlers.remove(handler);
  }
}