I'm using this package https://pub.dev/packages/ansicolor
And print with this function
String _colorMessage(LogLevel logLevel, String message) {
AnsiPen pen;
switch (logLevel) {
case LogLevel.error:
pen = AnsiPen()..red();
break;
case LogLevel.warning:
pen = AnsiPen()..yellow();
break;
case LogLevel.debug:
pen = AnsiPen()..white();
break;
case LogLevel.trace:
pen = AnsiPen()..gray(level: 0.5);
break;
}
return pen(message);
}

flutter logs
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.6 19G73, locale ru-RU)
• Flutter version 1.17.5 at /Users/vmeretin/dev/flutter
• Framework revision 8af6b2f038 (5 weeks ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at /Users/vmeretin/dev/android-sdk/
• Platform android-29, build-tools 30.0.1
• ANDROID_HOME = /Users/vmeretin/dev/android-sdk/
• ANDROID_SDK_ROOT = /Users/vmeretin/dev/android-sdk/
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.6, Build version 11E708
• CocoaPods version 1.9.3
[!] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
[!] IntelliJ IDEA Ultimate Edition (version 2020.2)
• IntelliJ at /Applications/IntelliJ IDEA.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] Connected device (1 available)
• iPhone SE (2nd generation) • 2207B74B-0056-43BB-A0AD-6B97703D8176 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
I think this is a limitation of the core IntelliJ console (see for example, https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000172019-IDEA-Run-Debug-Console-not-displaying-RGB-Ansi-codes-correctly-) but maybe @alexander-doroshko knows more?
/fyi @devoncarew
@pq @devoncarew For Dart Test and Dart Command Line App run configurations, it was fixed by using ColoredProcessHandler instead of OSProcessHandler. See this commit: https://github.com/JetBrains/intellij-plugins/commit/7c61483984e702013f794ce0600870267adfca09.
Fantastic. Thanks!
Any news on this?
From looking at this, it will require changes to the Flutter plugin (minor changes, as outlined by @alexander-doroshko above), as well as changes to the flutter command line tool. Somewhere in the pipeline it looks like we're escaping the escape char (into \^?), so the ansi handling in the ColoredProcessHandler class doesn't have the right info to act on.
As part of fixing the escaping issue, we can probably also do something about the leading flutter: text on print output from flutter apps.
If there are more issues about the ANSI handling, please file new issues and let me know, thanks! Before that, enjoy the colorful console. :-)
Most helpful comment
From looking at this, it will require changes to the Flutter plugin (minor changes, as outlined by @alexander-doroshko above), as well as changes to the flutter command line tool. Somewhere in the pipeline it looks like we're escaping the escape char (into
\^?), so the ansi handling in theColoredProcessHandlerclass doesn't have the right info to act on.As part of fixing the escaping issue, we can probably also do something about the leading
flutter:text on print output from flutter apps.