I just recently began using flutter, I am trying to implement firebase signing in using email and password and it works when I input the correct email and password but not when the password is wrong. It gives a PlatformException when the password is wrong and then the app freezes even though I've tried to catch the exception while android studio shows this below:
Here is my sign in implementation:
String _reason;
Future<void> _performLogin() async {
String reason;
// This is just a demo, so no actual login here.
try{
FirebaseUser user = await FirebaseAuth.instance.signInWithEmailAndPassword(email: _email, password: _password);
if(user != null){
Navigator.of(context).push(new MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return new MyApp();
},
));
final snack = new SnackBar(
content: new Text("Signed In Successfully"),
action: null,
duration: new Duration(seconds: 4),
backgroundColor: Colors.black,
);
Scaffold.of(context).showSnackBar(snack);
}
}on PlatformException catch(e){
reason = '${e.message}';
/*final snack = new SnackBar(
content: new Text(e.message),
action: null,
duration: new Duration(seconds: 4),
backgroundColor: Colors.black,
);
Scaffold.of(context).showSnackBar(snack);*/
}
setState(() {
_reason = reason;
});
}
I also added import 'package:flutter/services.dart' show PlatformException;
Please let me know how to catch the exception, thank you.