查找Flatter应用程序中Firebase Auth中是否已存在电子邮件和用户名

查找Flatter应用程序中Firebase Auth中是否已存在电子邮件和用户名,firebase,firebase-authentication,flutter,Firebase,Firebase Authentication,Flutter,我在我的Flatter应用程序中使用电子邮件注册,并使用Firebase身份验证。如何在注册页面上显示输入的电子邮件和用户名是否已存在于数据库中?firebase将以错误消息的形式返回该信息: FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password).then((user) { // do whatever you want to do with new user o

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

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
  });

如果电子邮件存在,它将触发捕获错误。值得注意的是,“细节”是人类可读的错误获取工具“代码”和“消息”对最终用户来说是无用的,但它们是firebase_auth上记录的仅有的两个

这管用!如果displayName已经存在,我该怎么做呢?您必须对自己的用户数据库进行检查。displayName在firebase中不是唯一的,只是电子邮件。