Set

A set in Dart is an unordered collection of unique items.

var halogens = {'fluorine', 'chlorine', 'bromine', 'iodine', 'astatine'};
var elements = <String>{}; 
elements.add('fluorine'); 
elements.addAll(halogens);
  • To create an empty set, use {} preceded by a type argument, or assign {} to a variable of type Set.
  • Use .length to get the number of items in the set.
  • Sets support spread operators (... and ...?) and collection ifs and fors, just like lists do.

Set — Structure map

Clickable & Draggable!

Set — Related pages: