splitByLength static method

List<String> splitByLength(
  1. String text,
  2. int length, {
  3. bool ignoreEmpty = false,
})

ccreate offset for tl

Implementation

static List<String> splitByLength(String text, int length,
    {bool ignoreEmpty = false}) {
  final List<String> pieces = [];

  for (int i = 0; i < text.length; i += length) {
    final int offset = i + length;
    String piece =
        text.substring(i, offset >= text.length ? text.length : offset);

    if (ignoreEmpty) {
      piece = piece.replaceAll(RegExp(r'\s+'), '');
    }

    pieces.add(piece);
  }
  return pieces;
}