max method

E? max(
  1. Comparator<E> compare
)

Returns the greatest element of this as ordered by compare, or null if this is empty.

Example:

['a', 'aaa', 'aa']
  .max((a, b) => a.length.compareTo(b.length)).value; // 'aaa'

Implementation

E? max(Comparator<E> compare) =>
    this.isEmpty ? null : this.reduce(_generateCustomMaxFunction<E>(compare));