fold, reduce, and expand
Aggregate and flatten iterables.
Aggregating a Collection
Often you want to collapse a whole list into one value, like a sum or a max. Dart gives you fold and reduce for exactly that. 🧮
Meet reduce
reduce combines elements pairwise using your function. It starts with the first item, so the list must not be empty.
var sum = [1, 2, 3, 4].reduce((a, b) => a + b);
print(sum); // 10