pretty_print 2.0.2
pretty_print: ^2.0.2 copied to clipboard
A powerful Dart library for terminal text styling with ANSI escape codes. Features 75+ extension methods and logging utilities.
π¨ 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.flutter-io.cn!
π 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



