allProviders method

Iterable<ProviderReference> allProviders({
  1. Family? family,
})

Returns all currently active providers in this container.

If family is specified, returns only the providers from that family. This is more efficient than allProviders().where((p) => p.provider.from == family).

The result includes providers mounted in this container and any of its parents, but does not include providers from child containers.

Note: Be careful about when you call this method, as you may otherwise miss providers that haven't been listened to yet.

For example if you do:

final args = ref.container.allProviders(family: myFamily);
ref.read(myFamily(0));

Implementation

Iterable<ProviderReference> allProviders({Family? family}) {
  final providers =
      family != null
          ? _pointerManager.listFamilyProviders(family)
          : _pointerManager.listProviders();

  if (container.parent case final parent?) {
    return providers.followedBy(parent.allProviders(family: family));
  }

  return providers;
}