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
ProviderScopeOverride
exists. -
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
ProviderScope
ancestor. -
If a
ProviderScope
ancestor 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
ProviderScope
ancestor, continuing recursively up the widget tree until the root is reached. -
If the provider is not found, a
ProviderWithoutScopeError
is thrown.