【问题标题】:I want to use streambuilder() and get the data from server only in firestore我想使用 streambuilder() 并仅在 firestore 中从服务器获取数据
【发布时间】:2020-04-29 07:43:58
【问题描述】:

您好,我正在使用 Flutter Firestore,并且我的动态数据每秒都在变化,所以我选择了用户 streabuilder(),但是我从 catch 获取数据的问题是我无法禁用的,任何人都知道如何我只能从服务器端设置流

这是我的代码:

      child: StreamBuilder(
          stream: firestore.collection("messages").snapshots(),
          builder: (context,snapShot){

            if(!snapShot.hasData) return Container();
            List<DocumentSnapshot> list = snapShot.data.documents;
            if(list.isNotEmpty){
              if(!list[0].metadata.isFromCache){
                return Container(

                );
              }
            }else{
              setState(() {

              });
            }
            return Container();
          },
        ),

【问题讨论】:

    标签: firebase flutter google-cloud-firestore


    【解决方案1】:

    我相信你可以指定你的信息流的来源:

    firestore.collection("messages").getDocuments(source: Source.server).asStream(),
    

    【讨论】:

      猜你喜欢
      • 2023-01-01
      • 1970-01-01
      • 2021-02-20
      • 1970-01-01
      • 2020-01-04
      • 2020-07-30
      • 1970-01-01
      • 2020-02-14
      • 1970-01-01
      相关资源
      最近更新 更多