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