ansi_colorizer 1.1.1 copy "ansi_colorizer: ^1.1.1" to clipboard
ansi_colorizer: ^1.1.1 copied to clipboard

An ANSI Escape Code support library that lets you apply custom formatting to your text.

ANSI Escape Code support library for Dart #

Use ANSI Escape Codes to apply some formatting to your text.

Can easily be globally disabled, by setting AnsiColorizer.enableColorizers to false.

Example #

import "package:ansi_colorizer/ansi_colorizer.dart";

void main() {
  // Create an AnsiColorizer object with your specific formatting options.
  const colorizer = AnsiColorizer(
    foreground: Ansi24BitColor.fromRGB(210, 200, 0),
    modifiers: {
      AnsiModifier.bold,
      AnsiModifier.italic,
    },
  );

  // Apply the formatting to the string representation of an object
  // by calling using the colorizer variable like a function.
  //
  // Alternatively you can also use:
  // final result = colorizer.colorize("Hello World");
  final result = colorizer("Hello World");

  // Prints "Hello World", but the text color is yellow and the
  // text is bold and cursive.
  print(result);
}
copied to clipboard

Colors #

This library supports 8 bit and 24 bit colors.

3 Bit #

This table represents all available colors.

table

...
// The standard color for cyan (see the color table).
final color = Ansi3BitColor(6);
...
copied to clipboard

All 3 bit colors can also be accessed with the Ansi3BitColors class.

...
final color = Ansi3BitColors.blue;
...
copied to clipboard

8 Bit #

This table represents all available colors.

table

...
// The standard color for red (see the color table).
final color = Ansi8BitColor(1);
...
copied to clipboard

24 Bit #

Create a color from a red, green and blue component.

...
final red = Ansi24BitColor(0xFF0000);
final green = Ansi24BitColor.fromRGB(0, 0xFF, 0);
...
copied to clipboard

Modifiers #

You can also apply a modifier from the AnsiModifier enum to make your text bold for example.

2
likes
150
points
87
downloads

Publisher

unverified uploader

Weekly Downloads

2024.08.28 - 2025.03.12

An ANSI Escape Code support library that lets you apply custom formatting to your text.

Repository (GitLab)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

meta

More

Packages that depend on ansi_colorizer