Question:
I am trying to asynchronously pull data from firestore in a streambuilder (all within a list view). The problem with the approach I have now is that nothing displays on the screen. I tried setting state (after i check if the screen is mounted, but to no avail). I know the correct data is being pulled because it prints to the screen, but for some reason, it just does not display on the screen.here’s a sample of my list view below:
Answer:
The problem is thatfriends[index]
is a future
. You did not await
it before returning GestureDetector
.return GestureDetector(...)
would be called before friends[index].then
callback. Variable friend
would still be null when return GestureDetector(...)
is called.The correct way to
wait
for it would be with a FutureBuilder
.Try this:
If you have better answer, please add a comment about this, thank you!