max method

int? max()

Returns the largest value of all elements If collection is empty this returns null.

Example:

[9, 42, 3].max(); // 42

Implementation

int? max() {
  return maxBy((a, b) => a.compareTo(b));
}