wrap method

String wrap(
  1. int width, {
  2. Pattern? whitespace,
  3. bool breakLongWords = true,
})

Wraps a long text so that every line is at most width characters long.

Implementation

String wrap(
  int width, {
  Pattern? whitespace,
  bool breakLongWords = true,
}) {
  checkNonZeroPositive(width, 'width');
  return split('\n')
      .map((line) =>
          line._wrap(width, whitespace ?? defaultWhitespace, breakLongWords))
      .join('\n');
}