ask static method
Prompts the user with a question and returns the entered value.
Returns defaultValue when the user provides no input and a default
value is available.
Implementation
static String ask(
String question, {
String? defaultValue,
}) {
if (defaultValue != null && defaultValue.isNotEmpty) {
stdout.write('$question [$defaultValue]: ');
} else {
stdout.write('$question: ');
}
final input = stdin.readLineSync()?.trim() ?? '';
if (input.isEmpty && defaultValue != null) {
return defaultValue;
}
return input;
}