šŸŽØ 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.dev!

šŸ“š 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

Libraries

pretty_print
A beautiful and customizable Dart library for printing colored and styled text to the terminal.