firebase - 为什么firebase颤振代码不起作用并出现错误?
问题描述
这是我无法理解的颤振代码来解决下面提到的问题。
`导入'包:cloud_firestore/cloud_firestore.dart';
class Book {
String bookName = "";
String authorName = "";
late DocumentReference documentReference;
Book(this.bookName,this.authorName);
Book.fromMap(Map<String, dynamic> map, this.documentReference) {
bookName = map["bookName"];
authorName = map["authorName"];}
Book.fromSnapshot(DocumentSnapshot snapshot)
:this.fromMap(snapshot.data, documentReference:snapshot.reference);
toJson(){
return{'bookName':bookName, "authorName": authorName};} }
运行代码时出现此错误
错误 :
需要 2 个位置参数,但找到了 1 个。参数类型“对象?Function()' 不能分配给参数类型'Map<String, dynamic>'。未定义命名参数“documentReference”。尝试将名称更正为现有命名参数的名称,或使用名称“documentReference”定义命名参数。尝试添加缺少的参数。
解决方案
推荐阅读
- java - 如何更新和避免“sun.net.www.protocol.https.Handler 是内部专有 API,可能会在将来的版本中删除”
- azure - 是否有用于 Microsoft 身份平台和 OAuth 2.0 授权的 OAuth 2 构建器?
- mysql - PK 和 FK 建模问题
- c# - 使用 EWS API (C#) 发送电子邮件时出现“未知邮箱”错误
- visual-studio - 使用 IIS 服务器时如何在 .NET Core 3.1 应用程序中运行代码?
- android-studio - 如何在Android中为数据对象提取字符串资源?
- flutter - 如何在构建有状态小部件之前等待功能?
- python - python - 如果缺少日期时间的条件
- spring-boot - 春季启动批处理 - ThreadPoolTaskExecutor 未处理所有线程
- r - R:如何使用 Pivot_wider 组合行