minBy<T> function

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

Implementation

T minBy<T>(Iterable<T> list, num Function(T) convert) {
  if ( list.isEmpty) {
    throw FlutterError('List Is Empty');
  }
  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;
}