Unique<E, Id> extension
An extension on List that provides functionality for handling unique elements
based on a specified identifier type Id
.
This extension can be used to add utility methods for extracting or filtering
unique elements from a list, where uniqueness is determined by a property or
identifier of type Id
.
Type Parameters:
E
: The type of elements in the list.Id
: The type used to determine uniqueness (e.g., a field or property ofE
).
Example usage:
final users = [User(id: 1), User(id: 2), User(id: 1)];
final uniqueUsers = users.uniqueBy((user) => user.id);
- on
-
- List<
E>
- List<