How can it update a list view elements without doing pull-to-refresh If I'm adding an element in a dialog window or from an Api, how to add/update the list view elements automatically.
Should I use StreamBuilder?
How can it update a list view elements without doing pull-to-refresh If I'm adding an element in a dialog window or from an Api, how to add/update the list view elements automatically.
Should I use StreamBuilder?
StreamBuilder Widget builds itself based on the latest snapshot of interaction with a Stream. Thus the state of the app changes whenever new elements are added in the list as long as the connection status is active.
You can also use the combination of ListView Builder and setState method, though the state of the app needs to change whenever a new element is added. Earlier StreamBuilder widget was updating the state of the app. Various methods like adding a button to the screen, which can help the user manually change the state; can be used depending on the use case.
You can read more about it from the official docs: setState method StreamBuilder
This answer is not exactly about updating listView, but updating a widget(PiChart). As listview is also a widget, the implementation will be the same to update without refreshing.
In this method, I am using streamBuilder to update the widget. so need not refresh the app to update the data.