min<T> function

T? min<T>(
  1. Iterable<T> i, [
  2. Comparator<T>? compare
])

Returns the minimum value in i, according to the order specified by the compare function, or null if i is empty.

The compare function must act as a Comparator. If compare is omitted, Comparable.compare is used. If i contains null elements, an exception will be thrown.

Implementation

T? min<T>(Iterable<T> i, [Comparator<T>? compare]) {
  if (i.isEmpty) return null;
  final Comparator<T> compare0 = compare ?? _compareAny;
  return i.reduce((a, b) => compare0(a, b) < 0 ? a : b);
}