šØ Pretty Print
A beautiful and customizable Dart library for printing colored and styled text to the terminal using ANSI escape codes. Perfect for CLI applications, debugging, and adding visual flair to your console output!
š¼ļø Visual Showcase
| šØ Colors & Text Styling | š Status Messages & Extensions | š Advanced Formatting & Effects |
|---|---|---|
![]() |
![]() |
![]() |
š Try it yourself: Run
dart run example/example.dartto see all features in action!
⨠Features
- šØ 8 Beautiful Colors: Black, Red, Green, Yellow, Blue, Magenta, Cyan, White
- š¼ļø Background Colors: Apply any color as background
- š Text Styling: Bold, Italic, Underline, Strikethrough
- ⨠Special Effects: Blinking animations, opacity control, hidden text
- š 75+ Extension Methods: Organized into 5 categories (Logging, Styling, Colors, Formatting, Debug)
- š Easy to Use: Simple, intuitive API with sensible defaults
- š Cross-Platform: Works on Windows, macOS, and Linux terminals
- š¦ Zero Dependencies: Lightweight and fast
- šÆ Type Safe: Full Dart type safety with enums
š Getting Started
Add this to your package's pubspec.yaml file:
dependencies:
pretty_print: ^1.0.0
Then run:
dart pub get
š Usage
Import the package:
import 'package:pretty_print/pretty_print.dart';
Basic Examples
// Traditional method
PrettyPrint.log("Hello World!", textColor: PrintColor.green);
PrettyPrint.log("Important!", textWeight: TextWeight.bold);
// Extension methods (recommended!)
"Success message".successLog(); // ā SUCCESS + green text
"Error occurred".errorLog(); // ā ERROR + red text
"Bold text".bold(PrintColor.red); // Bold red text
"Important notice".box(); // Boxed text
š Extension Methods Showcase
// Logging extensions
"Database connected".successLog();
"Loading configuration".infoLog();
"Deprecated method".warningLog();
"Connection failed".errorLog();
"Debug information".debugLog();
// Styling extensions
"Bold text".bold();
"Italic text".italic();
"Underlined text".underline();
"Blinking text".blink();
// Color extensions
"Red text".red();
"Green text".green();
" Alert ".onRed(); // Red background
"Bold blue text".boldBlue();
// Formatting extensions
"Application Title".header();
"Important message".box();
"Critical alert".doubleBox();
"First item".bullet();
"Step 1".numbered(1);
// Debug extensions
"Fix this bug".todo(); // š TODO
"Memory usage: 256MB".memory(); // š¾ MEMORY
"API took 89ms".benchmark(); // ā±ļø PERF
"userId".variable("12345"); // š¢ Variable
šØ Advanced Usage
Traditional Method
// Combine multiple styles
PrettyPrint.log("Warning!",
textColor: PrintColor.yellow,
textWeight: TextWeight.bold,
textUnderline: TextUnderLine.underline
);
// Animated text
PrettyPrint.log("Loading...",
textColor: PrintColor.cyan,
textBlink: TextBlink.slowBlink
);
Extension Method Combinations
// Chain multiple effects
"Critical Alert!".onRed().bold().blink();
// Professional output
"System Status Report".header();
"CPU Usage: 45%".benchmark();
"Memory: 256MB".memory();
"All systems operational".successLog();
š Common Use Cases
Status Messages (Quick & Easy!)
// Using extension methods (recommended)
"Operation completed successfully".successLog();
"Loading user preferences".infoLog();
"API endpoint deprecated".warningLog();
"Connection failed".errorLog();
"System debug info".debugLog();
CLI Applications
"š Application Startup".header();
"Loading configuration...".infoLog();
"Database connected".successLog();
"š System Status".box();
"CPU: 45%".benchmark();
"Memory: 256MB".memory();
"Connections: 1,247".network();
Development & Debugging
"Add user authentication".todo();
"Fix memory leak in cache".fixme();
"Performance looks good".note();
"userId".variable("user_123");
"isAuthenticated".variable(true);
"responseTime".variable("89ms");
Professional Output
"Application Report".header();
"".separator();
"System Metrics".leftAlign(20);
"Status: Online".rightAlign(15, PrintColor.green);
"Last Updated".leftAlign(20);
DateTime.now().toString().rightAlign(25, PrintColor.cyan);
š API Reference
šØ Available Colors
PrintColor.black,PrintColor.red,PrintColor.green,PrintColor.yellowPrintColor.blue,PrintColor.magenta,PrintColor.cyan,PrintColor.white
š Text Styling Options
TextWeight.bold/TextWeight.normalTextItalic.italic/TextItalic.noneTextUnderLine.underline/TextUnderLine.noneTextThroughLine.lineThrough/TextThroughLine.none
⨠Special Effects
TextBlink.slowBlink- Slow blinking animationTextBlink.fastBlink- Fast blinking animationTextBlink.semiOpacity- Semi-transparent textTextBlink.hide- Hidden text
š Extension Categories (75+ Methods)
š Logging (8 methods)
successLog(), infoLog(), warningLog(), errorLog(), debugLog(), criticalLog(), traceLog(), performanceLog()
šØ Styling (12 methods)
bold(), italic(), underline(), lineThrough(), blink(), fastBlink(), dim(), hide(), boldUnderline(), italicUnderline(), allEffects()
š Colors (25+ methods)
red(), green(), blue(), onRed(), onGreen(), boldRed(), boldGreen(), rainbow(), etc.
š Formatting (16 methods)
header(), box(), doubleBox(), separator(), leftAlign(), center(), bullet(), numbered(), indent(), quote(), code(), etc.
š Debug (16 methods)
todo(), fixme(), note(), debugPrint(), inspect(), variable(), benchmark(), memory(), network(), security(), etc.
// Debug info
PrettyPrint.pprint("[DEBUG]",
textColor: PrintColor.blue,
textWeight: TextWeight.bold
);
// Info message
PrettyPrint.pprint("[INFO]",
textColor: PrintColor.cyan
);
// Hidden sensitive data
PrettyPrint.pprint("Secret: password123",
textBlink: TextBlink.hide
);
šØ Available Options
Colors (PrintColor)
PrintColor.blackPrintColor.redPrintColor.greenPrintColor.yellowPrintColor.bluePrintColor.magentaPrintColor.cyanPrintColor.whitePrintColor.none(default)
Text Weight (TextWeight)
TextWeight.normalTextWeight.boldTextWeight.none(default)
Text Styling
TextItalic.italic/TextItalic.noneTextUnderLine.underline/TextUnderLine.noneTextThroughLine.lineThrough(strikethrough) /TextThroughLine.none
Blinking and Opacity Effects (TextBlink)
TextBlink.semiOpacity- Semi-transparent textTextBlink.hide- Hidden textTextBlink.slowBlink- Slow blinkingTextBlink.fastBlink- Fast blinkingTextBlink.none(default)
šÆ Complete Example
import 'package:pretty_print/pretty_print.dart';
void main() {
// Header
PrettyPrint.pprint("=== PRETTY PRINT DEMO ===",
textColor: PrintColor.white,
backColor: PrintColor.blue,
textWeight: TextWeight.bold
);
// Colors demonstration
print("\nšØ Colors:");
PrettyPrint.pprint("Red", textColor: PrintColor.red);
PrettyPrint.pprint("Green", textColor: PrintColor.green);
PrettyPrint.pprint("Blue", textColor: PrintColor.blue);
PrettyPrint.pprint("Yellow", textColor: PrintColor.yellow);
// Styling demonstration
print("\n⨠Styles:");
PrettyPrint.pprint("Bold text", textWeight: TextWeight.bold);
PrettyPrint.pprint("Italic text", textItalic: TextItalic.italic);
PrettyPrint.pprint("Underlined text", textUnderline: TextUnderLine.underline);
// Effects demonstration
print("\nš Effects:");
PrettyPrint.log("Blinking text", textBlink: TextBlink.slowBlink);
PrettyPrint.log("Semi-transparent", textBlink: TextBlink.semiOpacity);
// Status messages
print("\nš Status Messages:");
PrettyPrint.pprint(" SUCCESS ",
textColor: PrintColor.white,
backColor: PrintColor.green,
textWeight: TextWeight.bold
);
PrettyPrint.pprint(" WARNING ",
textColor: PrintColor.black,
backColor: PrintColor.yellow,
textWeight: TextWeight.bold
);
PrettyPrint.pprint(" ERROR ",
textColor: PrintColor.white,
backColor: PrintColor.red,
textWeight: TextWeight.bold
);
}
š ļø Terminal Compatibility
This package works with most modern terminals that support ANSI escape codes:
- ā Windows: Windows Terminal, PowerShell, Command Prompt (Windows 10+)
- ā macOS: Terminal.app, iTerm2, and other terminal emulators
- ā Linux: GNOME Terminal, Konsole, xterm, and most terminal emulators
- ā IDEs: VS Code integrated terminal, IntelliJ terminal, and others
š¤ Contributing
Contributions are welcome! If you have suggestions, bug reports, or want to contribute code:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
š License
This project is licensed under the MIT License - see the LICENSE file for details.
šØāš» Author
Mohamed Maher - GitHub
- š§ Email: mohamedmaher.personal@gmail.com
- š¼ LinkedIn: Mohamed Maher
- š Portfolio: Portfolio Website
ā Support
If you like this package, please give it a ā on GitHub and a š on pub.dev!
š More Packages
Check out my other packages:
id_generator- Generate secure, customizable random IDseasy_in_app_notify- Beautiful in-app notifications for Fluttermena- Middle East and North Africa country data utilities
Made with ā¤ļø by Mohamed Maher
Libraries
- pretty_print
- A beautiful and customizable Dart library for printing colored and styled text to the terminal.


