askYesNoQuestion static method

bool askYesNoQuestion(
  1. String title
)

Implementation

static bool askYesNoQuestion(String title) {
  log('\n$title (y/n)');
  bool? result;
  do {
    var line = stdin.readLineSync(encoding: utf8);
    final allowedValues = ['y', 'n', 'yes', 'no'];
    if (allowedValues.contains(line)) {
      result = line == 'y' || line == 'yes';
    } else {
      log('\nPlease enter y or n');
    }
  } while (result == null);
  return result;
}