Skip to content

Set Signal

A SetSignal is a special signal that can be used to represent a set of values.

When you modify any element on the set, the SetSignal will automatically notify its observers.

final items = SetSignal({1, 2});
items.observe((previousValue, value) {
print("Items changed: $previousValue -> $value");
});
items.add(3); // prints "Items changed: [1, 2] -> [1, 2, 3]"
items.remove(1); // prints "Items changed: [1, 2, 3] -> [2, 3]"