LinkedHashSet.from(Iterable<E> elements)

Create a linked hash set containing all elements.

Creates a linked hash set as by new LinkedHashSet<E>() and adds each element ofelements to this set in the order they are iterated.

All the elements should be assignable to E. The elements iterable itself may have any element type, so this constructor can be used to down-cast a Set, for example as:

Set<SuperType> superSet = ...;
Iterable<SuperType> tmp = superSet.where((e) => e is SubType);
Set<SubType> subSet = new LinkedHashSet<SubType>.from(tmp);

Source

factory LinkedHashSet.from(Iterable<E> elements) {
  LinkedHashSet<E> result = new LinkedHashSet<E>();
  for (final E element in elements) {
    result.add(element);
  }
  return result;
}