0
Good afternoon, I’m using the firebase_auth plugin: 0.20.0+1 to authenticate user.
When the user matches the login information no error is shown, however when the user is incorrect and an exception is generated, the flutter cannot capture the exception code.
class UserManager {
// config FIREBASE
final FirebaseAuth auth = FirebaseAuth.instance;
///
////sigin
Future<void> fazerLogin(
{Usuario usuario, Function onFail, Function onSuccess}) async {
// resultado a auteticação
try {
final UserCredential result = await auth.signInWithEmailAndPassword(
email: usuario.email,
password: usuario.senha,
);
} on PlatformException catch (e) {
onFail(getErrorString(e.code));
}
}
}
follows the console information
W/System ( 8621): Ignoring header X-Firebase-Locale because its value was null.
E/flutter ( 8621): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: [firebase_auth/wrong-password] The password is invalid or the user does not have a password.
E/flutter ( 8621): #0 MethodChannelFirebaseAuth.signInWithEmailAndPassword
package:firebase_auth_platform_interface/…/method_channel/method_channel_firebase_auth.dart:497
E/flutter ( 8621): <asynchronous suspension>
What’s your question? Want to know how to treat so that Flutter "understands" the exception of "Incorrect password?" and execute the
try-catch
? It wasn’t very clear...– Matheus Ribeiro