pretty_print library

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

This library provides an easy-to-use API for creating colorful and styled terminal output using ANSI escape codes. Perfect for CLI applications, debugging, and logging.

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, Blinking
  • πŸ“‹ 75+ Extension Methods: Organized into logical groups for easy discovery
  • πŸ”§ Grouped API: Methods organized by category (logging, styling, colors, formatting, debug)
  • πŸ“Š Advanced Formatting: Boxes, headers, separators, alignment, lists
  • πŸ› Development Tools: Debugging utilities, variable inspection, performance monitoring
  • 🌈 Special Effects: Rainbow text, animations, and visual enhancements
  • πŸš€ Cross-platform: Works on all platforms that support ANSI escape codes

Quick Start

Basic PrettyPrint.log Usage

import 'package:pretty_print/pretty_print.dart';

// Simple colored text
PrettyPrint.log(
  "Hello World!",
  textColor: PrintColor.green,
  textWeight: TextWeight.bold,
);

// Text with background color and styling
PrettyPrint.log(
  " SUCCESS ",
  textColor: PrintColor.white,
  backColor: PrintColor.green,
  textWeight: TextWeight.bold,
);
import 'package:pretty_print/pretty_print.dart';

// Logging methods
"Operation completed successfully!".logging.successLog();
"Application started".logging.infoLog();
"This feature is deprecated".logging.warningLog();
"Failed to connect to database".logging.errorLog();

// Text styling
"Bold text".styling.bold();
"Italic text".styling.italic();
"Underlined text".styling.underline();

// Colors
"Red text".colors.red();
"Green text".colors.green();
"Text on blue background".colors.onBlue();

// Formatting
"Title".formatting.header();
"Content".formatting.box();
"Left aligned text".formatting.leftAlign(30);

// Development & Debugging
"Debug message".debug.debugPrint();
"variable".debug.variable(someValue);
"Performance check".debug.benchmark();

Extension Groups

The library organizes methods into logical groups for better discoverability:

  • .logging: Status logging (success, error, info, warning, debug, critical, trace, performance)
  • .styling: Text styling (bold, italic, underline, strikethrough, blink, combinations)
  • .colors: Colors (red, green, blue, etc.) and backgrounds (onRed, onGreen, etc.)
  • .formatting: Layout (box, header, separator, alignment, lists, quotes, code blocks)
  • .debug: Development tools (debugPrint, variable inspection, performance, memory, network)

Advanced Features

// Rainbow text effect
"Rainbow text!".colors.rainbow();

// Complex formatting
"Important Title".formatting.header();
"Boxed content".formatting.box();
"Item 1".formatting.bullet();
"Step 1".formatting.numbered(1);

// Development utilities
"userName".debug.variable("john_doe");
"API Response".debug.inspect();
"Query took 150ms".debug.benchmark();

For complete documentation and examples, visit: https://pub.flutter-io.cn/packages/pretty_print

Classes

PrettyPrint
The main class for printing styled and colored text to the terminal.
PrettyPrintExtBase
Abstract base class for all extension groups.

Enums

PrintColor
Enum defining available colors for text and background styling.
Enum defining text blinking and opacity effects for terminal output.
TextItalic
Enum defining italic text styling for terminal output.
TextThroughLine
Enum defining line-through (strikethrough) text styling for terminal output.
TextUnderLine
Enum defining underline text styling for terminal output.
TextWeight
Enum defining text weight options for terminal output.

Extensions

PrettyPrintExt on String
Main extension on String that provides access to all grouped methods.

Constants

baseLeading β†’ const String
The leading part of an ANSI escape sequence.
baseTrailing β†’ const String
The trailing part of an ANSI escape sequence.
noneValue β†’ const String
Represents no value/empty string for enum options.