A Dart package to print colored text in terminals using CSS color names, hex codes, and RGB values.
- Supports CSS color names (red, blue, gold, etc.)
- Hex colors (#RGB, #RRGGBB, #RRRGGGBBB)
- RGB values (rgb(255,0,0) or rgb(255 0 0))
- Truecolor ANSI escapes (works on modern terminals)
- Graceful fallback on unsupported terminals
- CLI tool included
dart pub add pixelcolorimport 'package pixelcolor.dart';
void main() {
printColor('Hello in red!', 'red');
printColor('Hex orange', '#FF8C00');
printColor('RGB cyan', 'rgb(0 255 255)');
}dart run pixelcolor "Your text" color
Examples:
dart run pixelcolor "Success!" green
dart run pixelcolor "Warning" "#FFA500"
dart run pixelcolor "Custom" "rgb(100 200 50)"printColor(String text, String colorStr): Prints colored text (with error for invalid colors).List<int>? parseColor(String colorStr): Parses to [r,g,b] or null.String getAnsiColor(List<int> rgb): Returns ANSI escape string or empty.int calculate(): Legacy demo function.
CSS names like: red, blue, green, yellow, orange, pink, purple, etc. (20+ included, expandable).
Hex: #f00, #ff0000, etc.
RGB: rgb(255,0,0), rgb(255 0 0)
dart test
dart analyze- Works on Windows Terminal, iTerm2, most Linux/macOS terminals.
- Fallback to plain text if no ANSI support detected.
See lib pixelcolor.dart for full implementation.