add method

void add(
  1. Listenable notifier
)

Adds a new notifier. For GaanaNotifier, check if one with the same key already exists.

Implementation

void add(Listenable notifier) {
  if (notifier is GaanaNotifier) {
    if (_notifiers.any(
      (n) =>
          n is GaanaNotifier &&
          (n).runtimeType == notifier.runtimeType &&
          (n).key == notifier.key,
    )) {
      return;
    }
  } else {
    if (_notifiers.any((n) => n.runtimeType == notifier.runtimeType)) {
      return;
    }
  }
  _notifiers.add(notifier);
  notifier.addListener(_onChildChanged);
  notifyListeners();
}