pretty_print 1.0.0 copy "pretty_print: ^1.0.0" to clipboard
pretty_print: ^1.0.0 copied to clipboard

A beautiful and customizable Dart library for printing colored and styled text to the terminal using ANSI escape codes. Perfect for CLI applications and debugging.

🎨 Pretty Print #

pub package License: MIT

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!

✨ 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
  • πŸš€ 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 #

// Simple colored text
PrettyPrint.pprint("Hello World!", textColor: PrintColor.green);

// Bold text
PrettyPrint.pprint("Important!", textWeight: TextWeight.bold);

// Text with background color
PrettyPrint.pprint(" SUCCESS ",
  textColor: PrintColor.white,
  backColor: PrintColor.green
);

Advanced Styling #

// Combine multiple styles
PrettyPrint.pprint("Warning!",
  textColor: PrintColor.yellow,
  textWeight: TextWeight.bold,
  textUnderline: TextUnderLine.underline
);

// Animated text
PrettyPrint.pprint("Loading...",
  textColor: PrintColor.cyan,
  textAlphaAnim: AlphaAndAnim.slowAnim
);

// Italic text with background
PrettyPrint.pprint("Stylish text",
  textColor: PrintColor.white,
  backColor: PrintColor.magenta,
  textItalic: TextItalic.italic
);

Common Use Cases #

Success/Error Messages

// Success message
PrettyPrint.pprint(" βœ“ SUCCESS ",
  textColor: PrintColor.white,
  backColor: PrintColor.green,
  textWeight: TextWeight.bold
);

// Error message
PrettyPrint.pprint(" βœ— ERROR ",
  textColor: PrintColor.white,
  backColor: PrintColor.red,
  textWeight: TextWeight.bold
);

// Warning message
PrettyPrint.pprint(" ⚠ WARNING ",
  textColor: PrintColor.black,
  backColor: PrintColor.yellow,
  textWeight: TextWeight.bold
);

Progress Indicators

// Loading with animation
PrettyPrint.pprint("πŸ”„ Loading...",
  textColor: PrintColor.cyan,
  textAlphaAnim: AlphaAndAnim.slowAnim
);

// Completed task
PrettyPrint.pprint("βœ… Task completed",
  textColor: PrintColor.green,
  textDone: TextDone.done  // Strikethrough
);

Debug Information

// 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",
  textAlphaAnim: AlphaAndAnim.hide
);

🎨 Available Options #

Colors (PrintColor) #

  • PrintColor.black
  • PrintColor.red
  • PrintColor.green
  • PrintColor.yellow
  • PrintColor.blue
  • PrintColor.magenta
  • PrintColor.cyan
  • PrintColor.white
  • PrintColor.none (default)

Text Weight (TextWeight) #

  • TextWeight.normal
  • TextWeight.bold
  • TextWeight.none (default)

Text Styling #

  • TextItalic.italic / TextItalic.none
  • TextUnderLine.underline / TextUnderLine.none
  • TextDone.done (strikethrough) / TextDone.none

Special Effects (AlphaAndAnim) #

  • AlphaAndAnim.semiOpacity - Semi-transparent text
  • AlphaAndAnim.hide - Hidden text
  • AlphaAndAnim.slowAnim - Slow blinking
  • AlphaAndAnim.fastAnim - Fast blinking
  • AlphaAndAnim.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.pprint("Blinking text", textAlphaAnim: AlphaAndAnim.slowAnim);
  PrettyPrint.pprint("Semi-transparent", textAlphaAnim: AlphaAndAnim.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:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License #

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author #

Mohamed Maher - GitHub

⭐ 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 IDs
  • easy_in_app_notify - Beautiful in-app notifications for Flutter
  • mena - Middle East and North Africa country data utilities

Made with ❀️ by Mohamed Maher

1
likes
160
points
95
downloads

Publisher

verified publishermomaher.dev

Weekly Downloads

A beautiful and customizable Dart library for printing colored and styled text to the terminal using ANSI escape codes. Perfect for CLI applications and debugging.

Repository (GitHub)
View/report issues

Topics

#terminal #console #color #ansi #print

Documentation

API reference

License

MIT (license)

More

Packages that depend on pretty_print