ask_sync method

bool? ask_sync({
  1. List<String> positive = const [],
})

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? ask_sync({
  final List<String> positive = const [],
}) {
  final answer = prompt_sync();
  if (answer == null) {
    // ignore: avoid_returning_null
    return null;
  } else {
    return DC_YES_RESPONSES.contains(answer.toLowerCase()) || positive.contains(message.toLowerCase());
  }
}