AnsiStyle

A Dart package for creating ansi styled text within io environments.

Usage

Import the package:

import 'package:ansi_styles/ansi_styles.dart';

Use the AnsiStyle export to create styled text by chaining properties. For example:

void main() {
  print(AnsiStyles.red.underline('Underlined red text'));
  print(AnsiStyles.inverse.italic.green('Inverted italic green text'));
  print(AnsiStyles.cyan('Cyan text'));
  print(AnsiStyles.bgYellowBright.bold('Bold text with a yellow background'));
  print(AnsiStyles.bold.rgb(255,192,203)('Bold pink text'));
  print(AnsiStyles.strikethrough.bgRgb(255,165,0)('Strikethrough text with an orange background'));
}

Output preview:

ansi_styles_preview

To remove any ansi styling from text, call the strip() method:

String styledText = AnsiStyles.red.underline('Underlined red text');
String cleanText = AnsiStyles.strip(styledText);

License


Built and maintained with 💛 by Invertase.

Chat on Discord Follow on Twitter


Libraries

ansi_styles