distinct method

List<T> distinct()

Returns a new list with duplicate elements removed (preserves order).

[1, 2, 1, 3, 2].distinct() // [1, 2, 3]

Implementation

List<T> distinct() {
  final seen = <T>{};
  return where(seen.add).toList();
}