I have some Lists containing only strings, every string has an equal length. I want to convert these lists into a list that must have 4 items on each list.
For ex.
const _a = [
'0330',
'0355',
'0405',
'0415',
'0425',
'0450',
'0500',
'0525',
'0535',
'0545',
'0555',
'0620',
'0630',
'0655',
'0705',
'0715',
'0725',
'0750',
'0800',
'0845',
];
The result I want is like this...
const _a = [
['0330', '0355', '0405', '0415'],
['0425', '0450', '0500', '0525'],
['0535', '0545', '0555', '0620'],
['0630', '0655', '0705', '0715'],
['0725', '0750', '0800', '0845'],
];
> partition(List elements, int size) sync* { RangeError.checkValueInInterval(size, 1, null, "size"); for (var i = 0; i < elements.length; i += size) yield [...elements.getRange(i, i + size)]; }`. The one difference is that it takes a `List` as argument, which makes things so much easier. :)
– lrn Mar 25 '22 at 20:36