-1

I'm not sure if it is better to query await in initState or if it is better to create a FutureBuilder.

The FutureBuilder is constantly reorganized for each setState, and the animation effect is hidden due to the loading screen (It is a short time, but if the data is not completely ready, I set it to show the loading screen).

So in many situations, I think that using FutureBuilder is not a good idea, so I ask.

dontknowhy
  • 2,480
  • 2
  • 23
  • 67
  • @eyllanesc , Don't exclude Flutter from the title. FutureBuilder and initState are functions that exist only in Flutter. Excluding Flutter in the title is not suitable for the title. – dontknowhy Nov 23 '20 at 03:02

1 Answers1

1

Firestore direct query will return u stream of data which u can use using StreanBuilder widget and every update in ur firestore will get reflect there

On other hand query in FutureBuilder is just async & await function which get executed once

GJJ2019
  • 4,624
  • 3
  • 12
  • 22
  • if u r facing rebuilding of future builder on each state change u can view this question https://stackoverflow.com/questions/60990519/future-builder-keeps-rebuilding-on-every-setstate/60990674#60990674 – GJJ2019 Nov 23 '20 at 03:07
  • thanks but I think you misunderstood. first of all, I do not want to use StreamBuilder I just want to use simple query only once. and the way you suggested with the link is exactly the way you do initState, as I mentioned above. My question is that Future Builder is being called again through setState in various parts in many ways, so I am trying to confirm whether it is not good to use it. – dontknowhy Nov 23 '20 at 05:32
  • if u use it in `init` state then it will gets called once and yes `FutureBuilder` is very good widget to use for network calls – GJJ2019 Nov 23 '20 at 10:14