unique method

List<T> unique(
  1. dynamic getKey(
    1. T
    )
)

Implementation

List<T> unique(dynamic Function(T) getKey) {
  var distinctSet = <dynamic>{};
  var distinctList = <T>[];
  for (var item in this) {
    if (distinctSet.add(getKey(item))) {
      distinctList.add(item);
    }
  }
  return distinctList;
}