confirm method
Asks a y/n question and returns the boolean answer.
Enter submits the current default. Pressing y/n (case-insensitive)
submits immediately.
Implementation
Future<bool> confirm(
String message, {
bool defaultValue = false,
}) {
bool? pending;
var submitted = false;
return runOneShot<bool>(
(ctx, submit) {
if (submitted) {
_drawCompactAnswer(ctx, message, pending! ? 'Yes' : 'No');
submit(pending!);
return;
}
ctx.draw(
Confirm(
id: Key.symbol(#__inline_confirm),
message: message,
defaultValue: defaultValue,
onSubmit: (v) {
pending = v;
submitted = true;
},
),
Rect(ctx.area.x, ctx.area.y, ctx.area.width, 1),
);
},
theme: _theme,
terminal: _terminal(),
allowNonInteractive: _allowNonInteractive,
);
}