minOrNull property Null safety

T? minOrNull

A minimal element of the iterable, or null it the iterable is empty.

Implementation

T? get minOrNull {
  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;
}