hnadling alerts in flutter

12 Views Asked by At

I have included FirePeace in the program, but when I try to deal with login and registration errors, it works correctly, but the alert does not appear.

void _EroorMesage_Email() {
    showDialog(
        context: context,
        builder: (context) {
          return const AlertDialog(
            title: Text('The Email proveded is Already in use '),
            backgroundColor: Colors.black38,
          );
        }    );
  }

  void _EroorMesage_Password() {
    showDialog(
        context: context,
        builder: (context) {
          return const AlertDialog(
            title: Text('The Password proveded is Incorrect '),
            backgroundColor: Colors.black38,
          );
        }    );
  }
 Future signUserIn() async {
      try {
        await FirebaseAuth.instance.signInWithEmailAndPassword(
            email: _emilController.text, password: _passwordController.text);
        Navigator.of(context).pushReplacementNamed('/play');
  }     on FirebaseAuthException catch (e) {
        if (e.code == 'user-not-found') {
          _EroorMesage_Email();
          //print("No user found for that email.");
        }     else if (e.code == 'wrong-password') {
          //print("Wrong password provided for that user");
          _EroorMesage_Password();
        }
      }
    }
0

There are 0 best solutions below