查找Flutter App中的Firebase Auth中是否已存在电子邮件和用户名 [英] Find whether email and username already exist in Firebase Auth in Flutter App
本文介绍了查找Flutter App中的Firebase Auth中是否已存在电子邮件和用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Flutter应用中使用电子邮件进行注册,并使用Firebase身份验证进行注册.如何在注册页面上显示输入的电子邮件和用户名是否已存在于数据库中?
I am using sign up with email in my Flutter app and using Firebase Authentication for the same. How do I show on the sign up page whether the entered email and username already exist in the database?
推荐答案
firebase会将该信息作为错误消息返回:
firebase will return that info as an error message:
FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password).then((user) {
// do whatever you want to do with new user object
}).catchError((e) {
print(e.details); // code, message, details
});
如果电子邮件存在,则会触发catchError
.值得注意的是,细节"是人类可读的错误获取器. 代码"和消息"对最终用户没有用,但是在firebase_auth上仅有这两个.
if the email exists it'll trigger the catchError
. it's worth noting that 'details' is the human readable error getter. 'code' and 'message' are useless to an end user, but those are the only two documented on firebase_auth.
这篇关于查找Flutter App中的Firebase Auth中是否已存在电子邮件和用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文