For the moment, use whichever you think is best or the one you prefer. You should instead make a variable in your state and provide MyProvider value in initState(). context.read() internally returns Provider.of(context, listen: false).The dispose() method is intended for disposing your widget's state dependencies and controllers, so you shouldn't try to find ancestors of this widget at this point because your widget is already deleted from the widget tree. var appState Provider. Instead of creating a new provider for your dialog you can access to Provider using Provider.of function inside your dialog. It's not same as your global AppState instance. You need to change this: static final provider StateProvider ( (ref) > CounterState (), ) static final provider StateNotifierProvider ( (ref) > CounterState (), ) Please refer to the Riverpod documentation about the. ChangeNotifierProvider.value creates a new AppState instance and passes to your dialog.Before we begin, note that this article assumes you have an operational Flutter development environment on your machine, along with working knowledge of Flutter. The error description basically says it all. Firstly, you are not creating the correct provider to listen to a StateNotifier. In this article, we will be building a sample app with one of the best state management packages for Flutter: Provider.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |