confirm static method
Prompts the user to confirm a question.
Returns defaultValue when the user provides no input. Otherwise,
returns true when the entered value is y or yes.
Implementation
static bool confirm(
String question, {
bool defaultValue = false,
}) {
final prompt = defaultValue ? '(Y/n)' : '(y/N)';
stdout.write('$question $prompt: ');
final input = stdin.readLineSync()?.trim().toLowerCase() ?? '';
if (input.isEmpty) {
return defaultValue;
}
return input == 'y' || input == 'yes';
}