How to platform exception error flutter 2020

I am trying to get to get a dialog pop to indicate to the user that the email already exists, but I keep getting this error an the dialog pop doesn't show, have gone through similar solution but none seem to work any help will be appreciated

Exception has occurred. FirebaseAuthException ([firebase_auth/email-already-in-use] The email address is already in use by another account.)

Below is my authentication code

    void registerToFb() {
firebaseAuth
    .createUserWithEmailAndPassword(
        email: emailController.text, password: passwordController.text)
    .then((result) {
  dbRef.child(result.user.uid).set({
    "email": emailController.text,
    "age": ageController.text,
    "name": nameController.text
  }).then((res) {
    isLoading = false;
    Navigator.pushReplacement(
      context,
      MaterialPageRoute(builder: (context) => Home(uid: result.user.uid)),
    );
  });
}).catchError((err) {
  print(err);
  showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text("Error"),
          content: Text(err.message),
          actions: [
            FlatButton(
              child: Text("Ok"),
              onPressed: () {
                Navigator.of(context).pop();
              },
            )
          ],
        );
      });
});

}



Read more here: https://stackoverflow.com/questions/64398834/how-to-platform-exception-error-flutter-2020

Content Attribution

This content was originally published by Emmanuel at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: