flutter - 连接到 Firebase 时 Flutter 中的地图出现问题
问题描述
我有从我的云存储中获取数据的 Record3 类:
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>";
}
我将该字段添加display
到云 Firestore,现在我正在尝试将其添加到 record3 代码中。但是,线路存在问题display = map['display'];
。display
抛出错误:
The name 'display' is already defined.
Try renaming one of the declarations.
并map
抛出错误:
Undefined name 'map'.
Try correcting the name to one that is defined, or defining the name.
我不太确定如何修复这些错误,因为两者都已定义,所以我觉得这与display
在地图中添加和不更改变量有关?我不确定,所以任何帮助将不胜感激!
解决方案
将显示分配之前的行更改为ref = map['ref'],
用逗号而不是分号。
推荐阅读
- r - split() 中的错误 1:dim(X)[along] 中的错误:NA/NaN 参数
- node.js - 使用 CLI 创建的带有 MSSQL 的 Express 应用程序未正确连接到数据库
- python - pytest:如何定义强制命令行参数
- php - 如何更改 WordPress 重置密码的默认电子邮件重置链接
- angular - 带有浮动标签的 Angular Primeng 下拉菜单在第一次渲染时效果不佳
- html - Safari 上的 HTML5 视频问题
- java - 如何单击 ListView 项目并打开引用我单击的项目的 Activity?
- clojure - 通过特定键从映射集合中提取一组值
- node.js - 如何让 NodeJS 在生产中对用户隐藏路径错误(发生错误时)
- java - 如何解决 java.lang.module.ResolutionException:模块 stax.api 和 java.xml 将包 javax.xml.stream 导出到模块 javafx.baseEmpty?