minOrNull property Null safety

num? minOrNull

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

Implementation

num? get minOrNull {
  var iterator = this.iterator;
  if (iterator.moveNext()) {
    var value = iterator.current;
    if (value.isNaN) {
      return value;
    }
    while (iterator.moveNext()) {
      var newValue = iterator.current;
      if (newValue.isNaN) {
        return newValue;
      }
      if (newValue < value) {
        value = newValue;
      }
    }
    return value;
  }
  return null;
}