new to flutter and working on this error.
this is the code.
PROBLEM- I want to to show the text(your cart is empty!) when the firestore is empty. The text is displaying when the firestore document is empty but the problem is when firestore has some data to display, the text(your cart is empty!) will display and after a moment(0.5 sec) the data will display.
I don’t want to display the text (your cart is empty) even for a milliseconds when the firestore has data. I appreciate if you guys can light the bulb for me.
2
Answers
With FutureBuilder, the app is listening to changes to the database. What you are noticing is the latency between a change being made, and your app receiving it. This can never be absolute 0 because a reading device only sees a change after the change has been made. You can decrease this number with optic internet (fast internet connection) and by moving the database closer to where you are. There are multiple regions that you can choose from in order to get you as close as possible.
that happened because you didn’t get response yet for the database so to make sure that you received respond you will use
snapshot.hasData
I hope this work for you