Provider retrieval process
Refer to the following graph to understand how the providers are retrieved.
Steps
-
When a provider is injected, the first thing that is checked is if a
ProviderScopeOverrideexists. -
If it does, its internal map of overridden providers is checked to see if the provider is there.
-
If is there, the overridden value is returned.
-
Otherwise, the search continues for the first
ProviderScopeancestor. -
If a
ProviderScopeancestor is found, the provider is searched in its internal map of providers. -
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.
-
If the provider is not found, the search proceeds to the next
ProviderScopeancestor, continuing recursively up the widget tree until the root is reached. -
If the provider is not found, a
ProviderWithoutScopeErroris thrown.