chunks method
Splits string by chunks with specified size.
If string is empty than empty Intarbale will be returned.
If size less or equal 0, that ArgumentError will be raised.
Implementation
Iterable<String> chunks(int size) sync* {
if (isEmpty) return;
if (size <= 0) {
throw ArgumentError.value(size, 'size', 'Should be more than zero');
}
final total = length;
if (total <= size) {
yield this;
} else {
var start = 0;
do {
final end = start + size;
yield substring(start, min(end, total));
start = end;
} while (start < total);
}
}