-
-
Notifications
You must be signed in to change notification settings - Fork 942
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
Bad state: Tried to read a provider from a ProviderContainer that was already disposed #3661
Comments
Hi , again share a minimal reproducible example. |
Ok, I'll try to provide you simplified version of the code that causes this error |
rrousselGit
added
question
Further information is requested
and removed
needs triage
labels
Jul 22, 2024
you can reproduce this error with the next code:
file provider2.dart
test file:
|
Your + Future<void> printSum() async {
final sum = (await ref.read(provider2Provider.future)) + (await future);
print('sum is - $sum');
callSecond();
}
....
+ await providerContainer.read(provider1Provider.notifier).printSum(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
hi, it's me again
I think I found new trouble, I am still writing tests and my test calls two functions:
so, despite in my tests I listen to currentWSUrlProvider like this:
container.listen(currentWSUrlProvider, (_, __) {});
right after this line
in calculateActiveWSUrl function - currentWSUrlProvider disposed and I see such an error
when try to read
in calculateActiveWSUrl function
Bad state: Tried to read a provider from a ProviderContainer that was already disposed
this is my currentWSUrlProvider
and I see such logs also, so I assume that provider still has at least one listener:
new listener
new listener
current ws url - ActiveWSUrl.saved(wsUrl: mock_ws_url)
bye everyone
new url - mockWebrtcUrl1
Bad state: Tried to read a provider from a ProviderContainer that was already disposed
Expected behavior
Expected that provider will keep alive until it has at least one listener
The text was updated successfully, but these errors were encountered: