maxOrNull property

T? maxOrNull

A maximal element of the iterable, or null if the iterable is empty.

Implementation

T? get maxOrNull {
  var iterator = this.iterator;
  if (iterator.moveNext()) {
    var value = iterator.current;
    while (iterator.moveNext()) {
      var newValue = iterator.current;
      if (value.compareTo(newValue) < 0) {
        value = newValue;
      }
    }
    return value;
  }
  return null;
}