我想在列表中添加修复数据,以便在pdf报告中显示,这种方式不能正常工作--我的意思是,它们没有显示列表中的数据,并显示了一些错误--我不知道问题出在哪里?
未处理的异常:坏状态:字段不存在于DocumentSnapshotPlatform中“
theData() async {
await FirebaseFirestore.instance
.collection('QFS')
.snapshots()
.forEach((QuerySnapshot snapshot) {
for (int index = 0; index < snapshot.docs.length; index++) {
List<List> listOfData = [];
listOfData
.add({snapshot.docs[index]["commodity"]}.toList());
print(listOfData);
}
});
}发布于 2021-11-12 07:08:27
我认为您应该尝试使用forEach()循环来优化您的代码,而不是使用for()循环,并且应该尝试使用docsindex.get(‘docsindex.get’)而不是docsindex。
您可以参考这些堆栈溢出链接以获得更多的洞察力:Unhandled Exception: Bad state: field does not exist within the DocumentSnapshotPlatform、How to fix Bad state: field does not exist within the DocumentSnapshotPlatform。
https://stackoverflow.com/questions/69827625
复制相似问题