maxOrNull method

num? maxOrNull()
  • return the maximum value in the list
  • return null if isEmpty

Implementation

num? maxOrNull() {
  if (isEmpty) return null;
  num max = first;
  for (final n in this) {
    if (n > max) max = n;
  }
  return max;
}