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.
You should instead make a variable in your state and provide MyProvider value in initState(). Firstly, you are not creating the correct provider to listen to a StateNotifier. Note: If your application already uses flutterhooks, you can install the hooksriverpod package instead. In the case of your example, you'd transform your widget into a StatefulWidget then extract that HTTP call to the initState of your State: ChangeNotifierProvider ( create: () > UserService (), ), Share. 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. The first step is to add the latest version of flutterriverpod as a dependency to our pubspec.yaml file: dependencies: flutter: sdk: flutter flutterriverpod: 2.3.6. The error description basically says it all. Using Riverpod on Flutter web, it seems like a browser refresh does not go quite far up as void main but rebuilds the UI so the solution I'm going to try is to save state to shared preferences, using Freezed classes makes this easier with målassInstantce.ToJson () and then reloading with FromJson () in most likely InitState () of the UI.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |