这最初可能有效,但在 firebase 更新后,它现在给我这个错误。我在给出错误的部分添加了星号。错误消息已添加到代码下方。
import 'package:cloud_firestore/cloud_firestore.dart';
class Record {
final String name;
final int totalVotes;
final DocumentReference reference;
Record.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map['name'] != null),
assert(map['totalVotes'] != null),
name = map['name'],
totalVotes = map['totalVotes'];
Record.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(**snapshot.data**, reference: snapshot.reference);
@override
String toString() => "Record<$name:$totalVotes>";
}
class Voters {
String uid;
String voteId;
String markedVoteOption;
}
不能将参数类型“Map最佳答案
请尝试以下操作:
Record.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data(), reference: snapshot.reference);
data()
是一种方法: /// Contains all the data of this [DocumentSnapshot].
Map<String, dynamic> data() {
return _CodecUtility.replaceDelegatesWithValueInMap(
_delegate.data(), _firestore);
}
返回 Map<String, dynamic>
关于firebase - 参数类型 'Map<String, dynamic> Function()' 不能分配给参数类型 'Map<String, dynamic>',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63597313/