I'm trying to making a signin feature on my app using firebase auth on flutter.
There are many exceptions I have to deal with but I can't catch them at all.
Here is my code.
Future<void> onSubmitted(
String email, AnimationController controller, BuildContext context) async {
controller.repeat();
FirebaseAuth _auth = FirebaseAuth.instance;
try {
_auth.signInWithEmailAndPassword(email: email, password: "1");
} on PlatformException catch (e) {
debugPrint(e.toString());
} on FirebaseAuthException catch (e) {
debugPrint(e.toString());
}
}
This is simplified form for testing. Anyway it doesn't even reach the catch statement. It raises PlatformException before it reaches the catch statement. I don't understand.
The error code is like this.
Unhandled Exception: [firebase_auth/user-not-found] There is no user record corresponding to this identifier. The user may have been deleted.
I explicitly specified the type of the exception and it's supposed to print the error message but it doesn't even reach debugPrint() function.
How should I catch the exception?