reduceOrNull method

E? reduceOrNull(
  1. E combine(
    1. E value,
    2. E element
    )
)

Accumulates value starting with the first element and applying combine function from left to right to current accumulator value and each element.

Implementation

E? reduceOrNull(E Function(E value, E element) combine) {
  if (isEmpty) return null;

  final iterator = this.iterator..moveNext();
  E value = iterator.current;

  while (iterator.moveNext()) {
    value = combine(value, iterator.current);
  }

  return value;
}