confirm static method
Creates a boolean confirm prompt (Yes/No).
final result = SimplePrompts.confirm(
title: 'Delete file?',
message: 'Are you sure?',
).run();
Implementation
static SimplePrompt<bool> confirm({
required String title,
required String message,
String yesLabel = 'Yes',
String noLabel = 'No',
bool defaultYes = true,
PromptTheme theme = PromptTheme.dark,
}) {
return SimplePrompt<bool>(
title: title,
theme: theme,
initialValue: defaultYes,
buildBindings: (state) => KeyBindings.togglePrompt(
onToggle: () => state.value = !state.value,
onCancel: state.cancel,
),
render: (ctx, state) {
// Message with arrow
ctx.gutterLine(
'${ctx.lb.arrowAccent()} ${ctx.theme.bold}$message${ctx.theme.reset}');
// Yes/No buttons
final yes = state.value
? '${ctx.theme.inverse}${ctx.theme.accent} $yesLabel ${ctx.theme.reset}'
: '${ctx.theme.dim}$yesLabel${ctx.theme.reset}';
final no = !state.value
? '${ctx.theme.inverse}${ctx.theme.accent} $noLabel ${ctx.theme.reset}'
: '${ctx.theme.dim}$noLabel${ctx.theme.reset}';
ctx.gutterLine(' $yes $no');
},
);
}