max property
T
get
max
Returns the maximum value in the list.
Only works with numeric types (num, int, double). Throws StateError if the list is empty. Throws UnsupportedError for non-numeric types.
Implementation
T get max {
if (isEmpty) {
throw StateError('Cannot get max of empty list');
}
if (T == int || T == double || T == num) {
return reduce((a, b) => (a as num) > (b as num) ? a : b);
}
throw UnsupportedError('Max is only supported for numeric types');
}