maxBy<R extends Comparable> method

T? maxBy<R extends Comparable>(
  1. R f(
    1. T
    )
)

Returns the element with the maximum value of f, or null if empty.

Implementation

T? maxBy<R extends Comparable<dynamic>>(R Function(T) f) {
  if (isEmpty) return null;
  return reduce((a, b) => f(a).compareTo(f(b)) >= 0 ? a : b);
}