ListenableMap<K, V>.fromListenable constructor

ListenableMap<K, V>.fromListenable(
  1. Listenable listenable
)

This is a ChangeNotifier class that can be handled as a map.

When the contents of the map change, you will be notified of the change.

Implementation

factory ListenableMap.fromListenable(Listenable listenable) {
  if (listenable is ListenableMap<K, V>) {
    final map = ListenableMap<K, V>.from(listenable);
    listenable.addListener(map.notifyListeners);
    return map;
  } else if (listenable is ValueListenable<Map<K, V>>) {
    final map = ListenableMap<K, V>.from(listenable.value);
    listenable.addListener(map.notifyListeners);
    return map;
  } else {
    final map = ListenableMap<K, V>();
    listenable.addListener(map.notifyListeners);
    return map;
  }
}