sortedUsing method Null safety

List<T> sortedUsing(
  1. Comparable getter(
    1. T item
    )
)

Implementation

List<T> sortedUsing(Comparable getter(T item)) {
  final ts = [...this];
  return ts.sortedBy((a, b) {
    final f1 = getter(a);
    final f2 = getter(b);
    return f1.compareTo(f2);
  }).cast();
}