promptForAccountSelection method

  1. @override
Future<String> promptForAccountSelection(
  1. String message,
  2. List<String> options
)
override

Implementation

@override
Future<String> promptForAccountSelection(
    String message, List<String> options) async {
  print(message);
  for (int i = 0; i < options.length; i++) {
    print("${i + 1}. ${options[i]}");
  }

  // Read user's selection and validate input
  int choice = -1;
  while (choice < 1 || choice > options.length) {
    stdout.write("Enter choice [1-${options.length}]: ");
    choice = int.parse(stdin.readLineSync()!);
  }

  return options[choice - 1];
}