max method
T
max()
Returns the maximum value in the iterable.
Throws a StateError if the iterable is empty.
Example:
[1, 5, 3].max(); // 5
Implementation
T max() {
if (isEmpty) {
throw StateError('Cannot get max of an empty iterable');
}
return reduce((a, b) => a > b ? a : b);
}