min property
- @useResult
The element with the minimum value returned by this Order's function, or null
if empty.
final list = [('a', 2), ('b', 1), ('c', 3)];
list.order(by: (foo) => foo.$2).min; // ('b', 1)
Implementation
@useResult E? get min {
final iterator = _iterable.iterator;
if (!iterator.moveNext()) {
return null;
}
var min = iterator.current;
var minValue = _function(min);
while (iterator.moveNext()) {
final value = _function(iterator.current);
if (minValue.compareTo(value) > 0) {
min = iterator.current;
minValue = value;
}
}
return min;
}