Skip to content

Provider retrieval process

Refer to the following graph to understand how the providers are retrieved.

Graphical representation of provider scope providers retrieval behavior

Steps

  1. When a provider is injected, the first thing that is checked is if a ProviderScopeOverride exists.

  2. If it does, its internal map of overridden providers is checked to see if the provider is there.

  3. If is there, the overridden value is returned.

  4. Otherwise, the search continues for the first ProviderScope ancestor.

  5. If a ProviderScope ancestor is found, the provider is searched in its internal map of providers.

  6. If the provider is found, its value is returned. It the value was not computed yet (i.e. it is the first time a lazy provider is accessed), it will get created right before it is returned.

  7. If the provider is not found, the search proceeds to the next ProviderScope ancestor, continuing recursively up the widget tree until the root is reached.

  8. If the provider is not found, a ProviderWithoutScopeError is thrown.