【发布时间】:2022-09-23 07:33:03
【问题描述】:
我正在尝试从“savedGoal”集合中获取数据,但它以某种方式抛出错误(NoSuchMethodError)。但是,相同的代码脚本/语法对于同一个 firebase 项目的另一个集合来说绝对可以正常工作。请让我知道这里可能出了什么问题。这是我在 ininState() 中运行的脚本-
FirebaseFirestore.instance
.collection(\"savedGoals\")
.where(\'uid\', isEqualTo: FirebaseAuth.instance.currentUser.uid)
.get()
.then((value) {
value.docs.forEach((result) async {
if (result.data().isNotEmpty) {
setState(() {
goalAmount = result.data()[\'goalAmountFixed\'];
});
}
这是我在使用 \"savedGoal\" 集合时收到的错误截图 - enter image description here
这是firebase文档截图- enter image description here
-
这个错误有一些可能性。请分享您的 firebase 屏幕截图以获取更多参考,因为您的“savedGoals”中可能没有数据。
-
打印值并打印结果,看看你得到了什么输出?
-
我已使用 Firebase 集合和文档详细信息更新了我的问题。
-
@AhmadRaza 打印值为空
标签: flutter firebase google-cloud-firestore