Closed ablbol closed 3 years ago
Are you sure that your second state = state.copyWith(images: image)
is reached?
Maybe you have an exception before in this method.
Yes I am sure that the second state is reached. Since everyone is switching to Riverpod, I am switching too. I will try the StateNotifier over there. I will close this issue if you like. Thanks for your help.
I switched into StateNotifier in Riverpod and found out that I have the same problem. So I investigated some more and found out that the problem is that in MyProfileModel I don't have a good implementation of these two functions:
int get hashCode {}
bool operator ==(Object o) {}
Once I implemented them appropriately, things worked out well. I know that Freeze give me all that but I decided not to use it for now while learning about Riverpod and Provider.
Lessons learned: make sure all of your models implement the two functions above while using Riverpod or Provider. I will go ahead and close the issue.
I have two questions about StateNotifier.
I am using StateNotifier (EditMyProfileViewModel) which holds a state (MyProfileModel) shown below and it has addImage function that is supposed to upload an image and do few other things. The addImage function updates the state 2 times, after Future calls, and I noticed that only the first update will change the UI. The other state change does not change the UI.
Do I need to do anything to make all 2 state changes update the UI. I use copyWith to change the state. Please make sure to read the comments in the code.
In the UI, I have AlbumEditor widget. Please see comments.
Here is the code for the AlbumEditorImage