Firebase “扑动火炉店”;参数类型';地图<;字符串,动态>;函数()';can';不能分配给参数类型';地图<;字符串,动态>&引用;
我试图在firebase firestore中查看我的数据。但是这个错误出现在我的firestore_service.dart文件中。你能帮我解决这个错误吗 “无法将参数类型‘Map Function()’分配给参数类型‘Map” 这是我的火炉店服务Firebase “扑动火炉店”;参数类型';地图<;字符串,动态>;函数()';can';不能分配给参数类型';地图<;字符串,动态>&引用;,firebase,flutter,google-cloud-firestore,google-cloud-functions,flutter-web,Firebase,Flutter,Google Cloud Firestore,Google Cloud Functions,Flutter Web,我试图在firebase firestore中查看我的数据。但是这个错误出现在我的firestore_service.dart文件中。你能帮我解决这个错误吗 “无法将参数类型‘Map Function()’分配给参数类型‘Map” 这是我的火炉店服务 import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:esrimarket/note.dart'; import 'package:flutter/founda
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:esrimarket/note.dart';
import 'package:flutter/foundation.dart';
class FirestoreService {
static final FirestoreService _firestoreService =
FirestoreService._internal();
Firestore _db = Firestore.instance;
FirestoreService._internal();
factory FirestoreService() {
return _firestoreService;
}
getNotes(){
return _db
.collection('notes')
.snapshots()
.map((snapshot)=>snapshot.documents.map((doc)=>Note.fromMap(doc.data, doc.documentID)));
}
}
这是我的note.dart文件
class Note{
final String name;
final String price;
final String quantity;
final String id;
Note({this.name, this.price, this.quantity, this.id});
Note.fromMap(Map<String,dynamic> data, String id):
name=data["name"],
price=data["price"],
quantity=data["quantity"],
id=id;
}
课堂笔记{
最后的字符串名;
最终字符串价格;
最终串数量;
最终字符串id;
注意({this.name,this.price,this.quantity,this.id});
注意.fromMap(映射数据,字符串id):
名称=数据[“名称”],
价格=数据[“价格”],
数量=数据[“数量”],
id=id;
}
成员数据后缺少括号,因为它是一个函数:
Note.fromMap(doc.data(), doc.documentID)
^^