splitLineJoin method

String splitLineJoin(
  1. int maxLength, [
  2. String separator = "\n"
])

Split this String, that is a single long line (maybe without any linebreaks) into multiple Strings with a maximum length of maxLength. Linebreaks are assumes to be \n.

The lines are split where a whitespace is. The length of a line may be more than maxLength, if the long line has no whitespaces that allow it to be split into multiple lines.

The split lines are joined using separator.

Also see splitLine.

Implementation

String splitLineJoin(int maxLength, [String separator = "\n"]) {
  return splitLine(maxLength).join(separator);
}