strip static method

String strip(
  1. String line
)

Strip all ANSI escape sequences from line.

This method is useful for:

  • Logging messages without formatting
  • Calculating the number of printable characters
  • Storing plain text versions of formatted output

Example:

final colored = red('Hello World');
final plain = Ansi.strip(colored); // 'Hello World'

Implementation

static String strip(String line) =>
    line.replaceAll(RegExp('\x1b\\[[0-9;]+m'), '');