maxBy method
Returns the element of this
with the greatest value for sortKey
, or
null
if this
is empty.
This method is guaranteed to calculate sortKey
only once for each
element.
Example:
['a', 'aaa', 'aa'].maxBy((e) => e.length).value; // 'aaa'
Implementation
E? maxBy(Comparable<dynamic> Function(E) sortKey) {
final sortKeyCache = <E, Comparable<dynamic>>{};
return this.max((a, b) => sortKeyCompare<E>(a, b, sortKey, sortKeyCache));
}