下面是代码给我的错误和错误是“一个函数体必须提供。尝试添加一个函数体。”我已经尝试了两种方法,但仍然有相同的错误。
下面是代码
Map<String, dynamic> toJson() {
return {"uid": uid, "email": email, "name": name,};}
字符串
我也试过这个代码
Map<String, dynamic> toJson() =>
{"uid": uid, "email": email, "name": name,};
型
下面是主代码
import 'package:cloud_firestore/cloud_firestore.dart';
class UserModel {
final String uid;
final String name;
final String email;
UserModel({
required this.uid,
required this.name,
required this.email,
})
Map<String, dynamic> toJson() =>
{"uid": uid, "email": email, "name": name,};
static UserModel fromSnap(DocumentSnapshot snap) {
var snapshot = snap.data() as Map<String, dynamic>;
return UserModel(
uid: snapshot["uid"],
name: snapshot["name"],
email: snapshot["email"],
);
}
}
型
我该怎麽办?
1条答案
按热度按时间ih99xse11#
您忘记在
UserModel
构造函数后加上分号;
。字符串