首页 文章

在Flutter App中查找Firebase Auth中是否已存在电子邮件和用户名

提问于
浏览
1

我在Flutter应用中使用电子邮件注册并使用Firebase身份验证 . 如何在注册页面上显示输入的电子邮件和用户名是否已存在于数据库中?

1 回答

  • 3

    firebase会将该信息作为错误消息返回:

    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 . 它's worth noting that ' details ' is the human readable error getter. ' code ' and ' message'对最终用户没用,但这些只是firebase_auth中记录的两个 .

相关问题