max method

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

Returns the greatest number in this, or null if this is empty.

Example:

[104, 3, 18].max().value; // 104

If compare is provided, it will be used to order the elements.

Example:

[-47, 10, 2].max((a, b) =>
    a.toString().length.compareTo(b.toString().length)).value; // -47

Implementation

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