confirm method

bool confirm(
  1. String message, {
  2. bool defaultValue = false,
})

Implementation

bool confirm(String message, {bool defaultValue = false}) {
  if (level != Level.quiet) {
    final suffix = defaultValue ? '[Y/n]' : '[y/N]';
    stdout.write('$message $suffix ');
  }

  final input = stdin.readLineSync()?.trim().toLowerCase();
  if (input == null || input.isEmpty) return defaultValue;
  return input == 'y' || input == 'yes';
}