Flutter 连接到firebase时,贴图在颤振中出现问题
我有一个Record3类,它从我的云firestore获取数据:Flutter 连接到firebase时,贴图在颤振中出现问题,flutter,dart,Flutter,Dart,我有一个Record3类,它从我的云firestore获取数据: class Record3 { final String name; final int ref; final bool display; final DocumentReference reference; Record3.fromMap(Map<String, dynamic> map, {this.reference}) : assert(map['name'] != null)
class Record3 {
final String name;
final int ref;
final bool display;
final DocumentReference reference;
Record3.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map['name'] != null),
assert(map['ref'] != null),
assert(map['display'] != null),
name = map['name'],
ref = map['ref'];
display = map['display'];
Record3.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data(), reference: snapshot.reference);
@override
String toString() => "Record<$name:$ref:$display>";
}
并且map
抛出错误:
The name 'display' is already defined.
Try renaming one of the declarations.
Undefined name 'map'.
Try correcting the name to one that is defined, or defining the name.
我不太确定如何修复这些错误,因为这两个错误都是定义好的,所以我觉得这与添加
display
和不更改map中的变量有关?我不确定,所以任何帮助都将不胜感激 将显示分配前的行更改为ref=map['ref'],
用逗号代替分号。我不敢相信这就是我错过的哈哈,谢谢!!