I'm making a login/sign up and in the signup when i try to signup with the same email the app stoped, i added this line
case "email-already-exists":
errorMessage = "The email is already being used.";
break;
The problem is, it still doesn't work, the message shows up but the app still stop working. (but the message it's not the same
this is the code that i'm using for authentication
void signUp(String email, String password) async {
if (_formKey.currentState!.validate()) {
try {
await _auth
.createUserWithEmailAndPassword(email: email, password: password)
.then((value) => {postDetailsToFirestore()})
.catchError((e) {
_toastInfo(e!.message);
});
} on FirebaseAuthException catch (error) {
switch (error.code) {
case "invalid-email":
errorMessage = "Your email address appears to be malformed.";
break;
case "wrong-password":
errorMessage = "Your password is wrong.";
break;
case "user-not-found":
errorMessage = "User with this email doesn't exist.";
break;
case "user-disabled":
errorMessage = "User with this email has been disabled.";
break;
case "too-many-requests":
errorMessage = "Too many requests";
break;
case "operation-not-allowed":
errorMessage = "Signing in with Email and Password is not enabled.";
break;
case "email-already-exists":
errorMessage = "The email is already being used.";
break;
default:
errorMessage = "An undefined Error happened.";
}
_toastInfo(errorMessage!);
print(error.code);
}
}
}