wrapAnsi function

String wrapAnsi(
  1. String string,
  2. int columns, {
  3. bool? trim,
  4. bool? wordWrap,
  5. bool hard = false,
})

For each newline, wrap separately

Implementation

String wrapAnsi(
  String string,
  int columns, {
  bool? trim,
  bool? wordWrap,
  bool hard = false,
}) {
  return string
      .replaceAll(RegExp('\r\n'), '\n')
      .split('\n')
      .map((line) =>
          wrap(line, columns, trim: trim, wordWrap: wordWrap, hard: hard))
      .join('\n');
}