reduceOrNull<S> method
S?
reduceOrNull<S>(
- S operation(
- S acc,
- T
Accumulates value starting with the first element and applying operation
from left to right to current accumulator value and each element.
Returns null if the list is empty.
Implementation
S? reduceOrNull<S>(S Function(S acc, T) operation) {
final i = iterator();
if (!i.hasNext()) {
return null;
}
S accumulator = i.next() as S;
while (i.hasNext()) {
accumulator = operation(accumulator, i.next());
}
return accumulator;
}