我试着将每个用户的数据保存在云Firestore中,在Stackoverflow上搜索,感觉好坏参半,因为旧的解决方案在2024年给出了错误,同时我是新手,我下面的代码在按下注册按钮时创建了一个新用户,我如何也保存每个用户的数据呢?
onPressed: () async {
//show spinner
//create new account
try {
final credential = await _auth
.createUserWithEmailAndPassword(
email: email,
password: password,
);
print(widget.personIdentity);
if (widget.personIdentity == 'Student'){
Navigator.pushNamed(context, StudentScreen.id);
} else {
Navigator.push(context, MaterialPageRoute(
builder: (context) => const DriverScreen(dPersonIdentity: 'Driver'),
));
}
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
print('The password provided is too weak.');
} else if (e.code == 'email-already-in-use') {
print('The account already exists for that email.');
}
} catch (e) {
print(e);
}
},