yesNo static method

bool yesNo(
  1. String message
)

yesNo method is used to ask a question that has a yes or no answer. The message is the message that will be shown in the console. The method returns a boolean value. If the answer is yes, it returns true.

Implementation

static bool yesNo(String message) {
  var res = read("$message (y/n):");
  if (res.toLowerCase() == 'yes' || res.toLowerCase() == 'y') {
    return true;
  } else if (res.toLowerCase() == 'no' || res.toLowerCase() == 'n') {
    return false;
  } else {
    write("Invalid option!", CappColors.error);
    return yesNo(message);
  }
}