Skip to content

Commit

Permalink
docs: add note about big o notation
Browse files Browse the repository at this point in the history
  • Loading branch information
nank1ro committed Jan 28, 2025
1 parent a0f049f commit 958979e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/src/content/docs/core/providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ If the provider is not found, the search continues for the next `ProviderScope`

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

<Aside>
<Aside type="tip">
The error can be avoided by using `provider.maybeOf(context)`, which returns `null` if the provider is not found.
</Aside>

<Aside>
The lookup of a provider is __O(1)__ because it just involves a map lookup, in addition the tree is traversed using [getElementForInheritedWidgetOfExactType](https://api.flutter.dev/flutter/widgets/BuildContext/getElementForInheritedWidgetOfExactType.html) which is O(1) because it jumps from one InheritedWidget of type `T` to another, skipping the widgets in between.
</Aside>

0 comments on commit 958979e

Please sign in to comment.