Zip<I1, I2>.fromEvenListSplit constructor
Null safety
- List list
Creates a Zip by splitting the list in half and zipping the entries on the first half of the list with the entries of the equivalent index on the second half of the list. The list must have an even length or you will encounter an ArgumentError ex:
[1,2,3,4,5,6] -->
1,4 2,5 3,6
Implementation
/// 1,4
/// 2,5
/// 3,6
factory Zip.fromEvenListSplit(List list){
if (list.length % 2 != 0) {
throw ArgumentError('List must be even current at ${list.length}');
}
List<ZipItem<I1, I2>> newBaseList = [];
int halfOfList = list.length ~/ 2;
for (int i in range(halfOfList)){
newBaseList.add(ZipItem(list[i], list[i+halfOfList]));
}
return Zip(newBaseList);
}