-
I'm using riverpod to manage my app states and struggling with the last provider. Basically, I'm using Firebase auth provider and have a Firestore document (FirestoreUser) for each user that matches on auth uid. For the app to function properly I need to do the following:
Here are my providers.
To maintain the state of ProfileUser from the api I'm using StateNotifier and it's not working properly. The error I'm getting is Unhandled Exception: Bad state: Tried to use ProfileUserStateNotifier after
firestore_database.dart
api_service.dart
How can I make sure that I have uid from the auth provider, FirestoreUser initiated and ProfileUser object before any other action take place? Also, I'm not sure if I'm using the StateNotifer properly in my home screen as I'm checking for null and displaying progress indicator. What if the api call returns null in that case my home screen will be stuck in progress indicator.
Sorry, I'm new to Flutter and Riverpod so any code reference or link to tutorials to solve the issue I'm having would be highly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Can anyone help please? |
Beta Was this translation helpful? Give feedback.
-
Solved it using the code below, once issue is that the api is called twice for some reason when the FirestoreUser is updated.
|
Beta Was this translation helpful? Give feedback.
Solved it using the code below, once issue is that the api is called twice for some reason when the FirestoreUser is updated.