wrapText function

List<String> wrapText(
  1. String text,
  2. int width
)

Word-wraps text to width columns. Escape sequences are kept and take no space; words longer than a line are broken.

Implementation

List<String> wrapText(String text, int width) {
  final lines = <String>[];
  for (final paragraph in text.split('\n')) {
    lines.addAll(_wrapLine(paragraph, width < 1 ? 1 : width));
  }
  return lines;
}