minMax method

({E max, E min}) minMax({
  1. Comparator<E>? comparator,
  2. ({E max, E min}) orElse()?,
})

Returns the minimum and maximum of this Iterable at once. The elements need to be Comparable, unless a custom comparator is provided.

Throws a StateError if the iterable is empty, unless an orElse function is provided.

For example

[3, 1, 2].minMax()

returns (min: 1, max: 3).

Implementation

({E min, E max}) minMax(
        {Comparator<E>? comparator, ({E min, E max}) Function()? orElse}) =>
    (comparator ?? naturalCompare).minMaxOf(this, orElse: orElse);