简体   繁体   English

如果使用 flutter 在云 firestore 中更新数据,是否有一种方法可以自动更新页面中的数据

[英]Is there a way to automatically update the data in the page if a data is updated in cloud firestore using flutter

I want to make an app that will automatically update the displayed data if the data inside the cloud firestore has been updated by the admin or other user.我想制作一个应用程序,如果管理员或其他用户更新了 cloud firestore 中的数据,它将自动更新显示的数据。

What you're describing are known are realtime listeners in Firestore.您所描述的是 Firestore 中的实时侦听器。 You can attach one by calling onSnapshot on a reference to the data or query, and will then be called with the current data right away and subsequently whenever the data gets updated.您可以通过在对数据或查询的引用上调用onSnapshot来附加一个,然后将立即使用当前数据调用,随后在数据更新时调用。

To show this data in the UI of your Flutter app, you can use a StreamBuilder as shown in this example in the documentation.要在 Flutter 应用程序的 UI 中显示此数据,您可以使用StreamBuilder ,如文档中的示例所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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