visitAncestors method

void visitAncestors(
  1. void visitor(
    1. ProviderElementBase element
    )
)

Visit the ProviderElementBases that this provider is listening to.

A provider is considered as listening to this element if it either watch or listen this element.

This method does not guarantee that a provider is visited only once. If this provider both watch and listen an element, or if it listen multiple times to an element, that element may be visited multiple times.

Implementation

void visitAncestors(
  void Function(ProviderElementBase element) visitor,
) {
  _dependencies.keys.forEach(visitor);

  final subscriptions = _subscriptions;
  if (subscriptions != null) {
    for (var i = 0; i < subscriptions.length; i++) {
      final sub = subscriptions[i];
      if (sub is _ProviderStateSubscription) {
        visitor(sub.listenedElement);
      }
    }
  }
}