max method Null safety

E? max()

Returns the largest element or null if there are no elements.

Implementation

E? max() {
  final self = this;
  return self != null && self.isNotEmpty ? self.reduce(math.max) : null;
}