minOfWithOrNull<R> method
Returns the smallest value according to the provided comparator
among
all values produced by selector
function applied to each element in the
collection or null
if there are no elements.
Implementation
R? minOfWithOrNull<R>(
Comparator<R> comparator,
R Function(E element) selector,
) {
if (isEmpty) return null;
final iterator = this.iterator..moveNext();
var minValue = selector(iterator.current);
while (iterator.moveNext()) {
final value = selector(iterator.current);
if (comparator(minValue, value) > 0) minValue = value;
}
return minValue;
}