Firebase 颤振误差-“;参数不匹配的闭包调用:函数';[]和#x27;接收器:关闭:()=>;地图<;字符串,动态>;从函数';数据';:&引用;
在我的Flatter应用程序上显示Firestore的数据时,我遇到了这个问题 错误:Firebase 颤振误差-“;参数不匹配的闭包调用:函数';[]和#x27;接收器:关闭:()=>;地图<;字符串,动态>;从函数';数据';:&引用;,firebase,flutter,dart,google-cloud-firestore,flutter-layout,Firebase,Flutter,Dart,Google Cloud Firestore,Flutter Layout,在我的Flatter应用程序上显示Firestore的数据时,我遇到了这个问题 错误: Closure call with mismatched arguments: function '[]' Receiver: Closure: () => Map<String, dynamic> from Function 'data':. Tried calling: []("quizImgUrl") Found: []() => Map<String,
Closure call with mismatched arguments: function '[]'
Receiver: Closure: () => Map<String, dynamic> from Function 'data':.
Tried calling: []("quizImgUrl")
Found: []() => Map<String, dynamic>
数据库代码:
Future<void> addQuestionData(Map questionData, String quizId) async {
await FirebaseFirestore.instance
.collection("Quiz")
.doc(quizId)
.collection("QNA")
.add(questionData)
.catchError((e) {
print(e);
});
}
Future addQuestionData(映射questionData,字符串quizId)异步{
等待FirebaseFirestore.instance
.收集资料(“测验”)
博士(奎齐德)
.收集(“QNA”)
.add(问题数据)
.catchError((e){
印刷品(e);
});
}
好的,首先需要调用data()方法。然后可以获得索引项的值。应该是这样的:
return QuizTile(
imgUrl: snapshot.data.documents[index].data()["quizImgUrl"],
desc: snapshot
.data.documents[index].data()["quizDescription"],
title: snapshot.data.documents[index].data()["quizTitle"],
);
好的,首先需要调用data()方法。然后可以获得索引项的值。应该是这样的:
return QuizTile(
imgUrl: snapshot.data.documents[index].data()["quizImgUrl"],
desc: snapshot
.data.documents[index].data()["quizDescription"],
title: snapshot.data.documents[index].data()["quizTitle"],
);
这回答了你的问题吗?答案对你有帮助吗?这回答了你的问题吗?答案对你有帮助吗?