the problem here is whenever the data being edit and updated at my details page, when user navigate back to previous page which is profile page, the data not straight away updated. instead, user need to navigate back to homepage then enter profile page back to fetch the latest data.
i have tried to construct the Bloc cubit properly with ChatGPT help and implement the refreshIndicator()
but both didn't work. I was thinking maybe the navigation is not right? but im not sure how to debug this. it just kind of bad user experience. is it because im using 2 bloc provider? first at main page and second at profile tab bar page. below is the snippet code on how i construct the Bloc.
any kind of help is really appreaciated. thank you!!
Yes, if you want the data to remain synced throughout the app, there should be only one instance of ProfileContentCubit
created.
From the code you sent, I saw you had created two ProfileContentCubit
, which apparently have different states. What you update within the detail pages affects the 2nd cubit, while from the profile page, data is rendered according to 1st cubit's state.
Define ProfileContentCubit
inside BlocProvider
inside main.dart
, the biggest scope, so that from anywhere can access ProfileContentCubit
.
Get to know about BlocProvider
and BlocProvider.value
:
BlocProvider
practically creates new Bloc by using function assigned to create
,
While BlocProvider.value
only repropagates existing blocs.