I want to add a User into my List if there is no user with that name yet. Actually I generally want to avoid duplicates. As I didn't find something like myList.distinct(User.name) or something like that I did it with a for for loop and if else:
myList.add(customUser);
for (User user in myList) {
if (user.name == customUser.name)
myList.remove(user);
}
I was just wondering if there is a smarter way to solve this in dart for example with a stream. But I didn't find anything.