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

时间:2018-07-17 17:17:35

标签: firebase firebase-authentication flutter

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

1 个答案:

答案 0 :(得分: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。值得注意的是,“细节”是人类可读的错误获取器。 “代码”和“消息”对最终用户毫无用处,但在firebase_auth上仅记录了两个。