Reputation: 197
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?
Upvotes: 1
Views: 4263
Reputation: 3222
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.
Upvotes: 3