minBy<K extends Comparable<K>> method

T? minBy<K extends Comparable<K>>(
  1. K selector(
    1. T element
    )
)

Finds the minimum value based on a selector or returns null if empty or all null.

Implementation

T? minBy<K extends Comparable<K>>(K Function(T element) selector) =>
    validate().reduceOrNull(
        (a, b) => selector(a).compareTo(selector(b)) <= 0 ? a : b);