uniqueListen method

void uniqueListen(
  1. Symbol id,
  2. ChangeNotifier obj,
  3. void fn()
)

Listens and iterates through obj.addListener by calling fn. The listener is disposed in the dispose function.

Whenever you call uniqueListen we will make sure that clear any listener with the same id.

Implementation

void uniqueListen(Symbol id, ChangeNotifier obj, void Function() fn) {
  _sanity();

  obj.addListener(fn);

  final cur = _uniqueListeners[id];

  if (cur != null) {
    cur.item1.removeListener(cur.item2);
  }

  _uniqueListeners[id] = Tuple2(obj, fn);
}