简体   繁体   中英

How can I update the data automatically without refreshing the page in firebase flutter?

I have to display total number of Sales and pending sales in the dashboard. I have designed inside the container. I need to update that every time new sales adds to Firebase Firestore automatically. How can I achieve this.

You may use stream builder or future builder to get data without getting refresh every time.

Here is the docs:

=> https://api.flutter.dev/flutter/widgets/StreamBuilder-class.html
=> https://api.flutter.dev/flutter/widgets/FutureBuilder-class.html

I would suggest a Streambuilder which listens to Firebase document that has a field called "Sales" and when the field is modified it will automatically be updated in the UI ( Container widget)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM