'Dart (flutter) VScode debug console syntax / expression coloring / highlighting
Does anyone know how to color or highlight syntax or expressions in the debug console in dart (flutter) for VScode efficiently? Most of the code comes out blue, but for instance, I want to set regular print statements as a different color.
Solution 1:[1]
ANSI escape code can be used,
void main() {
printWarning("Warning");
printError("Error");
printInfo("Info");
printSuccess("Succes");
}
void printWarning(String text) {
print('\x1B[33m$text\x1B[0m');
}
void printError(String text) {
print('\x1B[31m$text\x1B[0m');
}
void printInfo(String text) {
print('\x1B[34m$text\x1B[0m');
}
void printSuccess(String text) {
print('\x1B[32m$text\x1B[0m');
}
Meaning of ANSI escape code is
\x1B:
ANSI escape sequence starting and ending marker[31m:
Escape sequence for red[0m:
Escape sequence for reset (stop making the text red)
For different colors:
Black: \x1B[30m
Red: \x1B[31m
Green: \x1B[32m
Yellow: \x1B[33m
Blue: \x1B[34m
Magenta: \x1B[35m
Cyan: \x1B[36m
White: \x1B[37m
Reset: \x1B[0m
For more reference refer https://stackoverflow.com/a/65622986/13431819
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Krishna Acharya |