The waiter cant bring everything together, so they sent one by one as it gets cooked.
So, here both of you have subscribed to the stream (food)
And you get them one by one as soon as its ready.
In this case, you are listening to incoming food (stream) and performs action on them (eat).
So this is how streams work in Dart!
If you got to learn something new from this thread, do like and retweet so that it can reach more wonderful developers like you ๐ฉ๐ปโ๐ป๐ง๐ปโ๐ป
Every time your UI refreshes (eg: using a setState), the future method is run again, which can turn out to be very expensive!
Sometimes this could be helpful, but most of the times itโs a curse for the application.
So how can you fix it ?
๐๐ป
We need to set the future in such a way that its run only once, and will never run again until you re-open the screen or you explicitly define a Swipe-down-to-refresh feature.
So, what is that one thing in Flutter, which will run only once in the entire life-cycle of your screen