promptSecret method

String promptSecret(
  1. String question
)

Asks the user for sensitive input (password, tokens, etc.) Input is hidden from display

Implementation

String promptSecret(String question) {
  stdout.write('$question ');
  stdout.flush();

  // Try to disable echo for password input
  try {
    stdin.echoMode = false;
    final input = stdin.readLineSync() ?? '';
    stdin.echoMode = true;
    print(''); // New line after hidden input
    return input.trim();
  } catch (e) {
    // Fallback if echoMode is not supported
    stdin.echoMode = true;
    warning('Warning: Input may be visible');
    return stdin.readLineSync()?.trim() ?? '';
  }
}