askSync method
Prompts a user for a yes or no answer.
The following are considered yes responses:
- yes
- y
- sure
- ok
- yep
- yeah
- true
- yerp
You can add more to the list of positive responses using the positive
argument.
The input will be changed to lowercase and then checked.
Implementation
bool? askSync({List<String> positive = const []}) {
var answer = promptSync();
if (answer == null) {
return null;
}
return _YES_RESPONSES.contains(answer.toLowerCase()) ||
positive.contains(message.toLowerCase());
}