Flutter: How to receive new Data and update Widget without rebuildung Flutter: How to receive new Data and update Widget without rebuildung dart dart

Flutter: How to receive new Data and update Widget without rebuildung


If you have a data source which constantly updates itself, you can use a StreamBuilder instead of FutureBuilder. StreamBuilder listens to the data source and rebuilds the widget after every update it gets from it.


My solution:In my use case it just wouldn't work with Streambuilder. The data that were passed into the Widget after new data came from the stream were the same somehow..Now I am using FutureBuilder to fetch the data initial and pass a Stream to my Widget. The Widget listens to changes on the Stream and updates itself..

Also, like mentioned from @RĂ©mi Rousselet, I start the fetch process in the initState method and assign it to a local future variable, instead of triggering the fetch directly with FutureBuilder.