Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error: Could not find the correct Provider<AssetPickerProvider<AssetEntity, AssetPathEntity>> above this Selector<AssetPickerProvider<AssetEntity, AssetPathEntity>, bool> Widget #345

Closed
gperez-88 opened this issue Aug 1, 2022 · 1 comment
Labels
i: not following issue template This issue is not following issue template. s: invalid This doesn't seem right.

Comments

@gperez-88
Copy link

gperez-88 commented Aug 1, 2022

when use AssetPicker.pickAssets(context); this error is thrown, then the image gallery is displayed.

i run on android, flutter 3.0.2

Error: Could not find the correct Provider<AssetPickerProvider<AssetEntity, AssetPathEntity>> above this Selector<AssetPickerProvider<AssetEntity, AssetPathEntity>, bool> Widget

This happens because you used a `BuildContext` that does not include the provider
of your choice. There are a few common scenarios:

- You added a new provider in your `main.dart` and performed a hot-reload.
  To fix, perform a hot-restart.

- The provider you are trying to read is in a different route.

  Providers are "scoped". So if you insert of provider inside a route, then
  other routes will not be able to access that provider.

- You used a `BuildContext` that is an ancestor of the provider you are trying to read.

  Make sure that Selector<AssetPickerProvider<AssetEntity, AssetPathEntity>, bool> is under your MultiProvider/Provider<AssetPickerProvider<AssetEntity, AssetPathEntity>>.
  This usually happens when you are creating a provider and trying to read it immediately.

  For example, instead of:

  Widget build(BuildContext context) {
    return Provider<Example>(
      create: (_) => Example(),
      // Will throw a ProviderNotFoundError, because `context` is associated

@gperez-88 gperez-88 added the await investigate The issue is waiting for further investigation. label Aug 1, 2022
@github-actions github-actions bot added the await triage The issue is waiting for triage. label Aug 1, 2022
@gperez-88 gperez-88 changed the title [BUG] Error with something [BUG] Error: Could not find the correct Provider<AssetPickerProvider<AssetEntity, AssetPathEntity>> above this Selector<AssetPickerProvider<AssetEntity, AssetPathEntity>, bool> Widget Aug 1, 2022
@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2022
@AlexV525
Copy link
Member

AlexV525 commented Aug 2, 2022

#28. Submit new issues to fill in all requirements in the issue template.

@AlexV525 AlexV525 added s: invalid This doesn't seem right. i: not following issue template This issue is not following issue template. and removed await triage The issue is waiting for triage. await investigate The issue is waiting for further investigation. labels Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i: not following issue template This issue is not following issue template. s: invalid This doesn't seem right.
Projects
None yet
Development

No branches or pull requests

2 participants