togglePrompt static method
KeyBindings
togglePrompt({
- required void onToggle(),
- KeyActionResult onConfirm()?,
- void onCancel()?,
- String toggleHint = 'toggle',
Standard toggle bindings: arrows toggle + space toggle + confirm + cancel.
Implementation
static KeyBindings togglePrompt({
required void Function() onToggle,
KeyActionResult Function()? onConfirm,
void Function()? onCancel,
String toggleHint = 'toggle',
}) {
return KeyBindings([
// All arrow keys toggle
KeyBinding.multi(
{
KeyEventType.arrowLeft,
KeyEventType.arrowRight,
KeyEventType.arrowUp,
KeyEventType.arrowDown,
},
(event) {
onToggle();
return KeyActionResult.handled;
},
hintLabel: '←/→',
hintDescription: toggleHint,
),
// Space also toggles
KeyBinding.single(
KeyEventType.space,
(event) {
onToggle();
return KeyActionResult.handled;
},
),
]) +
confirm(onConfirm: onConfirm) +
cancel(onCancel: onCancel);
}