maxByOrNull<R extends Comparable<R>> method

T? maxByOrNull<R extends Comparable<R>>(
  1. R by(
    1. T item
    ), [
  2. T? ifNull
])

Implementation

T? maxByOrNull<R extends Comparable<R>>(R by(T item), [T? ifNull]) {
  T? _max;
  for (final t in this) {
    if (_max == null || (by(t).compareTo(by(_max))) > 0) {
      _max = t;
    }
  }
  return _max ?? ifNull;
}