combineKeyEventResults function Null safety
- Iterable<
KeyEventResult> results
Combine the results returned by multiple FocusOnKeyCallbacks or FocusOnKeyEventCallbacks.
If any callback returns KeyEventResult.handled, the node considers the message handled; otherwise, if any callback returns KeyEventResult.skipRemainingHandlers, the node skips the remaining handlers without preventing the platform to handle; otherwise the node is ignored.
Implementation
KeyEventResult combineKeyEventResults(Iterable<KeyEventResult> results) {
bool hasSkipRemainingHandlers = false;
for (final KeyEventResult result in results) {
switch (result) {
case KeyEventResult.handled:
return KeyEventResult.handled;
case KeyEventResult.skipRemainingHandlers:
hasSkipRemainingHandlers = true;
break;
case KeyEventResult.ignored:
break;
}
}
return hasSkipRemainingHandlers ?
KeyEventResult.skipRemainingHandlers :
KeyEventResult.ignored;
}