How can I print colored debug messages with Flutter / Dart to show colored Android Studio console output?
I don't believe this is possible at this point. How this works exactly is still a bit unclear to me but it hinges on the supportsAnsiEscapes method. This outputs false
when running in Android Studio:
import 'dart:io' as io;
print(io.stdout.supportsAnsiEscapes);
Escape sequences are then simply ignored.
Note that even if this call would return true Android Studio only supports a limited subset of ANSI colors: https://youtrack.jetbrains.com/issue/IDEA-137065
Ride Sun
Updated on December 14, 2022Comments
-
Ride Sun over 1 year
How can I print colored debug messages with Flutter/Dart to show colored Android Studio console/logcat output? There are many dart packages that provide the escape characters for colored output but the Android Studio simply does not show them.
Some of them are: https://github.com/iamsalnikov/colorize or https://pub.dev/packages/ansicolor
Or simply some escape characters should work as well:
print('\x1B[94m $text \x1B[0m');
These messages show up like this:
[94m [36m57 2019-10-18 16:18:55.694098 FINE ui.app.dart: initial route = null[0m [0m
My question is, can I exchange the console to see the escape characters? Or just any other way?
-
pskink over 4 yearswhat OS? my android studio on linux shows colors with no problems
-
Ride Sun over 4 yearsWindows 10. The console is the on inside Android Studio.
-
pskink over 4 yearsthat console (ALT + F12)? or something else?
-
Ride Sun over 4 yearsThe debug output console. I am not add my computer right now.
-
Ride Sun over 4 yearsAlso logcat does not show the coloring
-
-
Ride Sun over 4 yearsSeems like the defect is around for the last 5 years
-
harm over 4 yearsIt does not inspire confidence.