我最近才开始使用flutter,我正在尝试使用电子邮件和密码来实现Firebase登录,当我输入正确的电子邮件和密码时,它可以工作,但是当密码错误时,它不能使用。当密码错误时,它将给出一个PlatformException,然后应用程序冻结,即使我在android studio显示以下情况时试图捕获该异常:
这是我的实施登录:
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), …Run Code Online (Sandbox Code Playgroud)