maxBy method

T? maxBy(
  1. Comparable<Object?> value(
    1. T item
    )
)

Item with the biggest value, or null when empty. products.maxBy((p) => p.price)

Implementation

T? maxBy(Comparable<Object?> Function(T item) value) => isEmpty ? null : reduce((T a, T b) => value(a).compareTo(value(b)) >= 0 ? a : b);