Comments (2)
When building for macos I have a problem when I resize the window. The provider is being disposed and I get something like this:
The following assertion was thrown building Consumer<BlahProvider>(dirty, dependencies: [_InheritedProviderScope<BlahProvider?>]): A BlahProvider was used after being disposed. Once you have called dispose() on a BlahProvider, it can no longer be used.
Any ideas?
This error occurs when you try to use a BlahProvider instance after it has been disposed of. When a ChangeNotifierProvider is removed from the widget tree or is no longer needed, its associated ChangeNotifier is disposed of using the dispose method. Once a ChangeNotifier has been disposed of, it can no longer be used, and any attempt to access its properties or call its methods will result in this error.
To fix this error, you should ensure that you are not using a disposed BlahProvider instance. This can be done by checking whether the BuildContext has access to a non-null BlahProvider instance using Provider.of(context, listen: false) or context.read() before using it. If the provider is null or has been disposed of, you should recreate the provider or avoid using it.
Additionally, you can also avoid this error by ensuring that you dispose of the ChangeNotifierProvider instance properly when it is no longer needed, such as when the widget that uses it is removed from the widget tree or when the state that uses it is no longer needed. This can be done by wrapping the widget tree that uses the provider in a Consumer widget, or by manually removing the provider from the widget tree using removeProvider method of the ProviderContainer.
from provider.
Closing as this was answered
from provider.
Related Issues (20)
- How do we pass widget parameters to the constructed changenotifier? Or is there a better alternative? HOT 5
- Function parameters cannot be the same as listener parameters HOT 1
- Can provider get and set states without widget context? HOT 1
- The "notifyListeners()" method of the mocked provider class is not rebuilding the widget. HOT 1
- MaterialApp's builder function breaks provider. Home: does not HOT 5
- 可以添加一个中文文档吗? HOT 1
- Provider variable Null check operator used on a null value HOT 1
- Use `Selector` with Records instead of Tuple HOT 3
- Provider<ThemeProvider> not found for Consumer<ThemeProvider> works in debug; broken in release. HOT 8
- Create a DevTools extension for `package:provider` HOT 3
- Provider<DateTime Function()> it's a good practice ? HOT 1
- Flag to shorten error output HOT 4
- Copied comment from stackoverflow HOT 1
- Provider Extensions HOT 1
- Inherited_provider.dart class _CreateInheritedProviderState<T> throws error when I pass in 440 as double? works with 440.0 HOT 1
- Provider 6.1.0 appears to be missing devtools extension assets HOT 2
- context.read CAN be called within build method HOT 1
- Trying to solve code duplication when working with lists of Widgets in Consumer HOT 4
- The shouldUpdate Selector method returns the same previous and next values HOT 1
- Listen to Changes from a Notifier HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from provider.