maxOrNull method Null safety

T? maxOrNull(
  1. [T? ifNull]
)

Implementation

T? maxOrNull([T? ifNull]) {
  T? _max;
  for (final t in this) {
    if (_max == null || t.compareTo(_max) > 0) {
      _max = t;
    }
  }
  return _max ?? ifNull;
}