Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 未处理的异常:错误状态:DocumentSnapshotPlatform中不存在字段_Flutter_Google Cloud Firestore - Fatal编程技术网

Flutter 未处理的异常:错误状态:DocumentSnapshotPlatform中不存在字段

Flutter 未处理的异常:错误状态:DocumentSnapshotPlatform中不存在字段,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,我试图从我的集合中检索一组数据,但每次运行代码时都会出现错误: “未处理的异常:错误状态:DocumentSnapshotPlatform中不存在字段”,并且未从firestore检索任何内容 代码如下: class EnterRefferal extends StatefulWidget { @override _EnterRefferalState createState() => _EnterRefferalState(); } class _EnterRefferalSt

我试图从我的集合中检索一组数据,但每次运行代码时都会出现错误:

“未处理的异常:错误状态:DocumentSnapshotPlatform中不存在字段”,并且未从firestore检索任何内容

代码如下:

class EnterRefferal extends StatefulWidget {
  @override
  _EnterRefferalState createState() => _EnterRefferalState();
}

class _EnterRefferalState extends State<EnterRefferal> {
  List<String> refId = [];
  void initState() {
    super.initState();
    FirebaseFirestore.instance
        .collection("clients")
        .get()
        .then((QuerySnapshot querySnapshot) => {
              setState(() {
                querySnapshot.docs.forEach((doc) {
                  refId.addAll([doc["refID"]]);
                });
              }),
            });
  }

  @override
  Widget build(BuildContext context) {
    print(refId);
类EnterRefferal扩展StatefulWidget{
@凌驾
_EnterRefferalState createState()=>\u EnterRefferalState();
}
类_enterreferalstate扩展状态{
列表refId=[];
void initState(){
super.initState();
FirebaseFirestore.instance
.收款(“客户”)
.get()
.然后((QuerySnapshot QuerySnapshot)=>{
设置状态(){
querySnapshot.docs.forEach((doc){
refId.addAll([doc[“refId”]]);
});
}),
});
}
@凌驾
小部件构建(构建上下文){
打印(重新打印);

请帮助我解决这个问题,提前谢谢。

您的收藏在firestore中是什么样子的?错误消息表明您的
客户
收藏中没有名为
refID
的字段。您能否共享您的firestore结构,以便我们检查您试图获取的内容?您的收藏在firestore中是什么样子的firestore?错误消息表明您的
客户端
集合中没有名为
refID
的字段。您能否共享您的firestore结构,以便我们检查您试图获取的内容?