split<T> static method
Split array colls: origin arrays size: split size
Implementation
static List<List<T>> split<T>(List<T> colls, int size) {
if (colls.isEmpty) {
return List.empty();
}
if (size <= 0) {
throw ArgumentError('the size must > 0');
}
List<List<T>> rets = [];
List<T> items = [];
for (var coll in colls) {
items.add(coll);
if (size == items.length) {
rets.add(items);
items = [];
}
}
if (items.isNotEmpty) {
rets.add(items);
}
return rets;
}