Skip to content

Map Signal

A MapSignal is a special signal that can be used to represent a map of values.

When you modify any element on the map, the MapSignal will automatically notify its observers.

final items = MapSignal({'a': 1, 'b': 2});
items.observe((previousValue, value) {
print("Items changed: $previousValue -> $value");
});
items.add({'c': 3}); // prints "Items changed: {'a': 1, 'b': 2} -> {'a': 1, 'b': 2, 'c': 3}"
items.remove('a'); // prints "Items changed: {'a': 1, 'b': 2, 'c': 3} -> {'b': 2, 'c': 3}"