remove static method
Removes the callback(s) associated with keybinding
from Keybinder.
If a callback
was provided, only that callback will be removed,
otherwise if callback
is null
, every callback bound to keybinding
will be removed.
Returns false
if the keybinding
isn't bound to any callbacks,
of if callback
was provided, but wasn't bound to keybinding
,
otherwise returns true
.
Implementation
static bool remove(Keybinding keybinding, [Function? callback]) {
if (!_keybindings.containsKey(keybinding)) {
return false;
}
// If a callback wasn't provided, remove the [keybinding]
// along with every callback bound to it.
if (callback == null) {
_keybindings.remove(keybinding);
return true;
}
final wasRemoved = _keybindings[keybinding]!.remove(callback);
// If there are no longer any callbacks registered to [keybinding],
// remove it from the map.
if (wasRemoved && _keybindings[keybinding]!.isEmpty) {
_keybindings.remove(keybinding);
}
return wasRemoved;
}