removeDuplicateProperties<T extends Model> static method

List<T> removeDuplicateProperties<T extends Model>(
  1. Iterable<T> source,
  2. String k
)

Returns a new list from source by removing duplicate properties with keys equal to k.

Implementation

static List<T> removeDuplicateProperties<T extends Model>(
  Iterable<T> source,
  String k,
) {
  final temp = List.of(source);
  final properties = <dynamic>{null};
  temp.removeWhere((m) {
    final json = m.toJson();
    final property = json[k];
    if (properties.contains(property)) {
      return true;
    }
    properties.add(property);
    return false;
  });
  return temp;
}