Q: How do I add unique elements to a List? In flutter/dart, how can I add elements to a list whilst ensuring that every new entry is unique (i.e. no duplicates). 
So we know how to add elements to a list:
List myList = [];

then
myList.add(...);

but I'd like to know how to make sure that whatever has been added has not been added before.
Many thanks,

A: You should consider using a set. A set is an unordered collection of unique items.
var mySet = <String>{};
mySet.add('something');


A: Optionally, you may use the Dart´s Extensions function
extension ListExtension<E> on List<E> {
   void addAllUnique(Iterable<E> iterable) {
     for (var element in iterable) {
       if (!contains(element)) {
         add(element);
       }
     }
   }
 }


A: Use a Map for the initial adding, Maps will not let duplicates then convert from Map to list.
Maps are Name Value pairs so if these are strings just set the name and value the same, if it is an object set the "uniqueID" as the name and the object as the value... 
Then you can take the Name set or usually Value set and turn that into a list for iteration and looping.
https://www.tutorialspoint.com/dart_programming/dart_programming_map.htm
