withoutDups property

List<T> get withoutDups

Returns a new list that contains the unique elements of the original list.

The getter converts the original list into a Set to remove duplicate elements, and then converts the Set back into a List.

Returns a new list without duplicate elements.

Example:

List<int> numbers = [1, 2, 3, 1, 4, 2, 5];
List<int> uniqueNumbers = numbers.withoutDups;
print(uniqueNumbers); // Output: [1, 2, 3, 4, 5]

Implementation

List<T> get withoutDups {
  return this.toSet().toList();
}