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?
Asked
Active
Viewed 4,121 times
1 Answers
3
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
});
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.
blaneyneil
- 3,122
- 13
- 14
-
This works! How would I do the same if displayName already exists? – Laksh22 Jul 19 '18 at 18:47
-
you'd have to do a check against your own user db. displayName is not unique in firebase, just email. – blaneyneil Jul 20 '18 at 05:17