【问题标题】:Where clause Google Cloud Firestore in StreamBuilderStreamBuilder 中的 Where 子句 Google Cloud Firestore
【发布时间】:2018-08-23 20:21:07
【问题描述】:

我想在流构建器中的云 Firestore 查询中添加 where 子句。我的问题是我的列表出现然后消失... 这是我的代码。

StreamBuilder(
      stream: Firestore.instance
          .collection('nomquetuveux')
          .orderBy('valid').where('valid', isEqualTo: true).snapshots(),
      builder: (context, snapshot) {
        if (!snapshot.hasData) return const Text('Chargement ...');
        return ListView.builder(
            itemCount: snapshot.data.documents.length,
            itemBuilder: (context, index) {
              return Column(children: <Widget>[
                _buildListItem(
                    context,
                    snapshot.data.documents[index]['libelle'],
                    snapshot.data.documents[index]['valid']),
                Divider(),
              ]);
            });
      }),

【问题讨论】:

    标签: firebase dart flutter google-cloud-firestore


    【解决方案1】:

    我认为您可以尝试通过执行以下操作来调试它。

    QuerySnapshot documents = await Firestore.instance
          .collection('nomquetuveux')
          .orderBy('valid').where('valid', isEqualTo: true)
          .getDocuments().catchError(
               (error) {print(error);}
          );
    

    这样就可以查看查询执行是否抛出了错误

    【讨论】:

      猜你喜欢
      • 2021-02-26
      • 2020-05-01
      • 1970-01-01
      • 2021-01-07
      • 2018-07-08
      • 2020-07-29
      • 2018-06-10
      • 2019-05-29
      相关资源
      最近更新 更多