Collections
Sets
Unique Members
A set literal <T>{...} stores unique values. Adding a duplicate is a no-op.
Program
Play the program to add a duplicate and a new color, then read the length.
sets.dart
void main() {
var colors = <String>{'red', 'green'};
colors.add('red');
colors.add('blue');
print(colors.length);
}
set literal
`<String>{...}` declares an empty-or-seeded set.
uniqueness
Adding an existing element does not grow the set.
length
`length` reports the number of unique entries.