maxOrNull method

T? maxOrNull()

Returns the largest element or null if there are no elements.

Implementation

T? maxOrNull() {
  final i = iterator();
  if (!iterator().hasNext()) return null;
  T max = i.next();
  if (max.isNaN) return max;
  while (i.hasNext()) {
    final T e = i.next();
    if (e.isNaN) return e;
    if (max < e) {
      max = e;
    }
  }
  return max;
}