I am developing a login system, using firebase, flutter and vscode.
I would like to know how to handle exceptions generated by Firebase. If EMAIL is already registered.
Currently generating an error:
Exception has occurred.
PlatformException (PlatformException(ERROR_EMAIL_ALREADY_IN_USE, The email address is already in use by another account., null))
If the email is already registered, I want to inform the user.
CODE:
Future<void> signUp({@required Map<String, dynamic> userData,@required String pass,@required VoidCallback onSuccess,@required VoidCallback onFail}) async{
isLoading = true;
notifyListeners();
_auth.createUserWithEmailAndPassword(
email: userData["email"],
password: pass
).then((user) async{
firebaseUser = user;
await _saveUserData(userData);
onSuccess();
isLoading = false;
notifyListeners();
}).catchError((e){
print(e);
onFail();
isLoading = false;
notifyListeners();
});
}