简体   繁体   English

如何使用Cloud Firestore从抖动中的数据快照中获取特定值?

[英]How do I get specific values from a datasnapshot in flutter using cloud firestore?

Data from the snapshot isn't storing in the variables (_gender, _email, verify). 快照中的数据未存储在变量(_gender,_email,验证)中。

    Firestore.instance.collection('Matrimonial').where('email', isEqualTo: _userEmail)
      .snapshots().listen(
            (data) {
              setState(() {
                this._gender = data.documents[0]['gender'];
                this._verify = data.documents[0]['verify'];
              });
            } 
      );

Maybe the query isn't correct, please help ? 也许查询不正确,请帮忙?

I think you forgot to add ".data" after the array of snapshots, try this. 我认为您忘了在快照数组之后添加“ .data”,请尝试此操作。

Firestore.instance.collection('Matrimonial').where('email', isEqualTo: _userEmail)
      .snapshots().listen(
            (data) {
              setState(() {
                this._gender = data.documents[0].data['gender'];
                this._verify = data.documents[0].data['verify'];
              });
            } 
      );

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

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