prompt static method
Implementation
static Future<String> prompt(String message, {bool hideInput = false}) async {
//YELLOW BACKGROUND BLACK TEXT
message.write(inYellow);
" ".write(inBlack);
// for each char being typed if hideInput is true then print a * otherwise print the char (handle backspace)
var input = "";
while (true) {
var char = stdin.readByteSync();
if (char == 127) {
if (input.length > 0) {
input = input.substring(0, input.length - 1);
stdout.write("\b \b");
}
} else if (char == 10 || char == 13) {
break;
} else {
input += String.fromCharCode(char);
if (hideInput) {
stdout.write("*");
} else {
stdout.write(String.fromCharCode(char));
}
}
}
stdout.writeln();
return input;
}