distinct method

Iterable<T?> distinct()

Returns a new iterable with duplicates removed, preserving nulls.

Example:

Iterable<int?>? numbers = [1, 2, 2, 3, null, null];
final distinct = numbers.distinct();
print(distinct);  // Output: [1, 2, 3, null]

Implementation

Iterable<T?> distinct() =>
    this == null ? Iterable.empty() : validate().toSet();