Hello everyone! I'm developing a widget that must...
# glance
r
Hello everyone! I'm developing a widget that must be updated based on the user interaction with the app, I've noticed that the updateAll function of the widget doesn't work every time it's called, so the widget doesn't get updated every time I call that method, but if I kill the app, reopen it and interact with the screen that calls that method, the method does update the widget (I've also tried to update the specific widget using the ID and get the same results). Is this an expected behavior?
s
Yes. When you call updateAll it delegates to the update method behind the scenes. The update method then checks if your widget is currently updating, and if it is it debounces that request. If I understand your problem, I think you should try having your widget get its state from a stateflow, and have that stateflow populated from an object like a repository.
r
Thanks! that worked, I'm now getting a Flow from a repository that returns what I need to show in my widget, I still need to call updateAll or update the specific widget with its ID to make it work.