I Got This Weird Error:
"The name 'FirebaseAuthExceptions' isn't a type and can't be used in an on-catch clause."
TextButton(
onPressed: () async {
final email = _email.text;
final password = _password.text;
try { final userCredential =
await FirebaseAuth.instance.signInWithEmailAndPassword (
email: email,
password: password,
);
print(userCredential);
} on FirebaseAuthExceptions catch (e){
If (e.code == 'user-not-found') {
print("User is not Found");
} Else if (e.code == 'wrong password') {
print("Wrong Password");
}
}
},
child: Text("LogIn"),
),
CodePudding user response:
It will be FirebaseAuthException
instead of FirebaseAuthExceptions
(extra s is the typo) and if
, else
should be start with small letter on dart
onPressed: () async {
final email = _email.text;
final password = _password.text;
try {
final userCredential =
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
print(userCredential);
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
print("User is not Found");
} else if (e.code == 'wrong password') {
print("Wrong Password");
}
}
},
CodePudding user response:
Use FirebaseAuthException instead of FirebaseAuthExceptions, remove 's'
Good Day!!!