BlocBuilder getting error becuase of this widget.
Closed this issue · 10 comments
Version
3.0.0
Library
feedback_sentry
Flutter channel
stable
Flutter version
3.19.2
Platform
Android
Details
Inside an alert dialogue I placed a BlocBuilder , This block builder widget is not rendering because of BetterFeedBack.
Error: -
Error: Could not find the correct Provider above this SupplierPopup 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 SupplierPopup is under your MultiProvider/Provider.
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 // to the widget that is the parent of `Provider<Example>` child: Text(context.watch<Example>().toString()), ); }
consider using
builder
like so:Widget build(BuildContext context) { return Provider<Example>( create: (_) => Example(), // we use `builder` to obtain a new `BuildContext` that has access to the provider builder: (context, child) { // No longer throws return Text(context.watch<Example>().toString()); } ); }
Steps to reproduce
- Create an alert dialogue .
- Wrap the content with any of the blocBuilder from flutter_bloc package
- call showDialog function and observe the result .
Output of flutter doctor -v
No response
So you have some code I can just copy paste and try? Even though your description is very detailed, it doesn't have enough information for me to be able to reproduce it.
Please check this sample app https://github.com/ilyasarafath/test-feedback
Also if alert dialogue is opened and try to click device back button the dialogue is still visible and page under dialogue is got popped .
I updated the code in same above repository . Pease check
@ilyasarafath could you plz try to reproduce this bug with the latest changes in the branch of the PR #293, this brach
I have the hunch that it has to do with the same bug (i have not test it myself, sorry, don't have the time)
@ueman @JesusHdez960717 I also facing this issue. The above issue not working.
@ilyasarafath did find any solution
@JesusHdez960717 It is working fine
@ueman Can you merge this PR and add to feedback_sentry plugin ?
Hello @ilyasarafath, thanks for the round of testing on this issue.
Unfortunately, although the solution proposed in PR #293 resolves this issue and some others related to dialogs and navigation in general, it also generates some strange behavior.... such as in the case of using a dialog in the custom feedback , this is only displayed at the bottom...
Considering this, we are still looking for the best possible solution to the problem, a solution that solves the problem without generating these strange behaviors and even more so, avoids possible new errors in the future.
BTW, in the PR there are more details, examples and screenshots of what is happening
hi @ilyasarafath, the PR that solves this bug is finally merged, if you want test it again to make sure and in case the bug is not reproduced any more, feel free to close this issue
It is working fine in latest version 3.1.0
So closing this ticket - @JesusHdez960717