split method

Iterable<String> split (
  1. String str,
  2. int length
)

Splits string based on desired length

Implementation

static Iterable<String> split(String str, int length) sync* {
  var last = 0;
  while (last < str.length && ((last + length) < str.length)) {
    yield str.substring(last, last + length);
    last += length;
  }
  yield str.substring(last, str.length);
}