getSecureEntry method
- String prompt = '> ',
Fonction permettant de cacher le résultat de l'entrée standard à l'écran, utilisé lorsqu'un mot de passe est demandé ?
Implementation
Future<String> getSecureEntry({String prompt = '> '}) async {
// Dumb function to cover dart lack of secure keyboard entry capabilities (doesn't print stdin to the screen when the secure entry is written by the user)
// Doesn't work on windows for some weird reason
if (!Platform.isWindows){
stdin.echoMode = false;
stdin.lineMode = false;
}
stdout.write(prompt);
String pass = stdin.readLineSync() ?? "";
if (!Platform.isWindows){
stdin.echoMode = true;
stdin.lineMode = true;
}
return pass;
}