Android studio Dart是在异步方法中使用WAIT时跨代码行的

Android studio Dart是在异步方法中使用WAIT时跨代码行的,android-studio,dart,flutter,Android Studio,Dart,Flutter,在我的颤振项目中,我有以下代码: if(await model.login(loginMailTextController.text, loginPasswordTextController.text)){ Navigator.of(context).pushReplacementNamed("/main"); } 此代码在我的模型中调用此函数: Future<bool> login(String mail, String password) async { _

在我的颤振项目中,我有以下代码:

if(await model.login(loginMailTextController.text, 
   loginPasswordTextController.text)){
   Navigator.of(context).pushReplacementNamed("/main");
}
此代码在我的模型中调用此函数:

Future<bool> login(String mail, String password) async {
   _auth.signInWithEmailAndPassword(email: mail, password: password);
   return true; //Makes no sense, only for testing
}
那么if语句中的表达式为false。此外,当在标记行上设置断点时,调试器不会停止。将断点设置到带有Email和Password的
登录方法上就像charme一样

这是一个错误还是我犯了错误?

“if statement Is false”看起来像是
wait\u auth.signin with Emailand Password(
抛出,异常未报告或类似


试着用Try/catch

来包装代码,你说的是哪个
if
语句?我也遇到了这个问题,可惜几个月来它变得更好了。在
print('foo');
行前面加上
wait
通常(并非总是)有助于使调试器表现得更好。@RémiRousselet'if(wait model.login(loginmailextcontroller.text,loginPasswordTextController.text))'@GünterZöchbauer你向dart或Flift团队报告了吗?@GünterZöchbauer最后一条评论是解决方案,我刚刚在VS代码中打开它,异常被抛出,只有在Android Studio中没有。谢谢你的帮助!写一个答案,我会接受并投票!
Future<bool> login(String mail, String password) async {
   await _auth.signInWithEmailAndPassword(
   email: mail, password: password);
   return true; //Debugger won't stop there when a breakpoint is set
}