colorText function
Implementation
String colorText([String color = "reset"]) {
bool isIOs = false;
try {
isIOs = Platform.isIOS || Platform.isMacOS;
} catch (_) {}
/// Get color text ASCII codes
///
if (isIOs) {
switch (color.toLowerCase()) {
case "red":
return "🟥";
case "yellow":
return "🟨";
case "green":
return "🟩";
case "blue":
return "🟦";
case "reset":
return "";
default:
return "";
}
} else {
String prefix = "\x1B";
switch (color.toLowerCase()) {
case "red":
return "$prefix[31m";
case "yellow":
return "$prefix[33m";
case "green":
return "$prefix[32m";
case "blue":
return "$prefix[34m";
case "reset":
return "$prefix[0m";
default:
return "$prefix[0m";
}
}
}