directionalNavigation static method
Creates all-direction navigation bindings (↑/↓/←/→).
Implementation
static KeyBindings directionalNavigation({
void Function()? onUp,
void Function()? onDown,
void Function()? onLeft,
void Function()? onRight,
String hintLabel = '↑/↓/←/→',
String hintDescription = 'navigate',
}) {
final bindings = <KeyBinding>[];
if (onUp != null) {
bindings.add(KeyBinding.single(
KeyEventType.arrowUp,
(event) {
onUp();
return KeyActionResult.handled;
},
));
}
if (onDown != null) {
bindings.add(KeyBinding.single(
KeyEventType.arrowDown,
(event) {
onDown();
return KeyActionResult.handled;
},
));
}
if (onLeft != null) {
bindings.add(KeyBinding.single(
KeyEventType.arrowLeft,
(event) {
onLeft();
return KeyActionResult.handled;
},
));
}
if (onRight != null) {
bindings.add(KeyBinding.single(
KeyEventType.arrowRight,
(event) {
onRight();
return KeyActionResult.handled;
},
hintLabel: hintLabel,
hintDescription: hintDescription,
));
}
return KeyBindings(bindings);
}