get<T extends Listenable> method

T? get<T extends Listenable>({
  1. bool predicate(
    1. T
    )?,
  2. String? key,
})

Returns the first notifier of type T that matches the optional predicate or key. if could also return a Notifier by its unique key

Implementation

T? get<T extends Listenable>({bool Function(T)? predicate, String? key}) {
  for (final notifier in _notifiers) {
    if (notifier is T) {
      if (notifier is GaanaNotifier && key != null) {
        if (notifier.key != key) continue;
      }
      if (predicate == null || predicate(notifier)) {
        return notifier;
      }
    }
  }
  return null;
}