MapSignal#
class & function |
Package: package:signals_core
Class: MapSignal#
A reactive Signal that holds a Map and implements the Map interface.
MapSignal lets you listen to changes on a map reactively and mutate it directly using
standard map operations (like adding/modifying keys with operator []=,
addAll, remove,
clear, etc.). Any mutations automatically trigger reactive updates to all active listeners
(e.g., inside an effect or computed).
Additionally, MapSignal defines convenient operators:
<<injects/adds all entries from another map into the current map.-
&forks/concatenates the map with another map into a new MapSignal. -
|pipes/concatenates the map with another signal holding a map into a new MapSignal.
Example Usage#
import 'package:signals/signals.dart';
void main() {
final settings = mapSignal<String, dynamic>({
'theme': 'light',
'notifications': true,
});
effect(() {
print('Theme is currently: ${settings['theme']}');
}); // Prints: "Theme is currently: light"
// Update key/value pair directly (triggers updates)
settings['theme'] = 'dark'; // Prints: "Theme is currently: dark"
// Expose standard Map methods
settings.remove('notifications');
}
settings.value = ... manually!
Members of MapSignal#
| Member | Type | Signature | Description |
|---|---|---|---|
| MapSignal | constructor |
dart MapSignal(super.value, {MapSignalOptions<K, V>? options, @Deprecated('Use options: MapSignalOptions(autoDispose: ...) instead') bool? autoDispose, @Deprecated('Use options: MapSignalOptions(name: ...) instead') String? debugLabel})
|
Creates a MapSignal with the given value. |
| << | method |
dart MapSignal<K, V> <<(Map<K, V> other) |
Inject: Update current signal value with iterable |
| & | method |
dart MapSignal<K, V> &(Map<K, V> other) |
Fork: create a new signal with value is the concatenation of source signal and iterable parameter |
| ** | ** | method |
dart MapSignal<K, V> |
| == | method |
dart bool ==(Object other) |
|
| hashCode | method |
dart int hashCode |
Function: mapSignal#
MapSignal<K, V> mapSignal(Map<K, V> map, {MapSignalOptions<K, V>? options, @Deprecated('Use options: MapSignalOptions(autoDispose: ...) instead') bool? autoDispose, @Deprecated('Use options: MapSignalOptions(name: ...) instead') String? debugLabel})
Creates a MapSignal initialized with the provided map.
This is a convenience helper function for creating reactive map signals.
import 'package:signals/signals.dart';
final settings = mapSignal({'theme': 'dark'});
References#
The MapSignal type is referenced and used in the following pages:
- Signal (signals_flutter/core)
- SignalsMixin (signals_flutter/mixins)
- IterableSignalMixin (signals_flutter/mixins)
- MapSignal (signals_flutter/value)
- IterableSignal (signals_flutter/value)
- signals_flutter
- Signal (signals_core/core)
- IterableSignalMixin (signals_core/mixins)
- MapSignal (signals_core/value)
- IterableSignal (signals_core/value)
- signals_core
- Signal (signals/core)
- SignalsMixin (signals/mixins)
- IterableSignalMixin (signals/mixins)
- MapSignal (signals/value)
- IterableSignal (signals/value)
- signals
- useMapSignal (signals_hooks/hooks)