promptUser function

String promptUser(
  1. String question
)

Prompts the user with a question in orange and waits for input.

Returns:

  • 'y' if the user responds with yes.
  • 'n' if the user responds with no or gives no input.

Example:

final answer = promptUser("Do you want to continue?");
if (answer == 'y') {
  printSuccess("Continuing...");
}

Implementation

String promptUser(String question) {
  stdout.write('$_orange$question (y/n): $_reset');
  return stdin.readLineSync()?.toLowerCase() ?? 'n';
}