maxBy<T> function

T maxBy<T>(
  1. Iterable<T> list,
  2. num convert(
    1. T
    )
)

Implementation

T maxBy<T>(Iterable<T> list, num Function(T) convert) {
  if (list.isEmpty) {
   throw FlutterError('列表为空');
  }
  num v=convert.call(list.first);
  T result=list.first;
  for (var v2 in list) {
    var tv = convert.call(v2);
    if(tv.compareTo(v)>0){
      v = tv;
      result = v2;
    }
  }
  return result!;
}