我已经研究 flutter 几个月了,我开始了解如何解决 null 安全问题,但这对我来说真的很复杂,我希望得到帮助。
这是我的问题:
每当我尝试登录时,都会收到此错误: 'Null' 类型不是 Map<string,dynamic> 类型的子类型 我尽力找出问题所在,但我无法,任何帮助都将是拯救生命...
import 'package:cloud_firestore/cloud_firestore.dart';
class User {
final String email;
final String uid;
final String photoUrl;
final String username;
final String bio;
final List followers;
final List following;
const User({
required this.email,
required this.uid,
required this.photoUrl,
required this.username,
required this.bio,
required this.followers,
required this.following,
});
Run Code Online (Sandbox Code Playgroud)
然后我继续在这里
Map<String, dynamic> toJson() => {
"username": username,
"uid": uid,
"email": email,
"photoUrl": photoUrl,
"bio": bio,
"followers": followers,
"following": following,
};
static User fromSnap(DocumentSnapshot snap) …
Run Code Online (Sandbox Code Playgroud) 所以基本上我有一个在 300 秒后过期的访问令牌,我需要在当前日期时间上添加 30 分钟并保存该日期时间以检查访问令牌是否过期