首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将修复数据添加到List<List>中

如何将修复数据添加到List<List>中
EN

Stack Overflow用户
提问于 2021-11-03 15:34:50
回答 1查看 80关注 0票数 0

我想在列表中添加修复数据,以便在pdf报告中显示,这种方式不能正常工作--我的意思是,它们没有显示列表中的数据,并显示了一些错误--我不知道问题出在哪里?

未处理的异常:坏状态:字段不存在于DocumentSnapshotPlatform中“

代码语言:javascript
复制
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);
    }
  });
}
EN

回答 1

Stack Overflow用户

发布于 2021-11-12 07:08:27

我认为您应该尝试使用forEach()循环来优化您的代码,而不是使用for()循环,并且应该尝试使用docsindex.get(‘docsindex.get’)而不是docsindex。

您可以参考这些堆栈溢出链接以获得更多的洞察力:Unhandled Exception: Bad state: field does not exist within the DocumentSnapshotPlatformHow to fix Bad state: field does not exist within the DocumentSnapshotPlatform

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69827625

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档