这最初可能有效,但在 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 Function()”无法分配给参数类型“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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)