Flatter firebaseauth注销()不工作
我正在使用firebase auth注销方法,但它似乎工作不正常。当我点击注销按钮时,它应该将当前用户注销。但是,执行此操作后,控制台不会指示firebase auth注销方法实际正在工作,无 应用程序有一个系统,如果用户在线,则在打开应用程序时,他们将始终被重定向到主页,除非他们从应用程序注销(他们将被重定向到登录页面)。当打开应用程序时,应用程序总是将我重定向到主页,因此很明显,即使在我按下注销按钮后,firebase auth注销方法也不起作用Flatter firebaseauth注销()不工作,firebase,flutter,dart,firebase-authentication,Firebase,Flutter,Dart,Firebase Authentication,我正在使用firebase auth注销方法,但它似乎工作不正常。当我点击注销按钮时,它应该将当前用户注销。但是,执行此操作后,控制台不会指示firebase auth注销方法实际正在工作,无 应用程序有一个系统,如果用户在线,则在打开应用程序时,他们将始终被重定向到主页,除非他们从应用程序注销(他们将被重定向到登录页面)。当打开应用程序时,应用程序总是将我重定向到主页,因此很明显,即使在我按下注销按钮后,firebase auth注销方法也不起作用 Authentication authent
Authentication authentication = Authentication();
logOutCurrentUser(BuildContext context) {
try {
authentication.logOut();
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LoginSignupToggle(true)), (route) => false);
}
catch (e) {
print(e.toString());
}
}
这是我的注销方法,它位于Authentication
类中
FirebaseAuth _auth = FirebaseAuth();
logOut() async {
return await _auth.signOut();
}
这是回调,单击注销按钮时会调用logOutCurrentUser
函数
Authentication authentication = Authentication();
logOutCurrentUser(BuildContext context) {
try {
authentication.logOut();
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LoginSignupToggle(true)), (route) => false);
}
catch (e) {
print(e.toString());
}
}
总而言之,即使在我按下注销按钮后,FirebaseAuth.instance.currentUser()
仍然不是null,我希望注销后它是null
我已尽可能多地搜索答案,但似乎没有任何效果我猜您的注销已中止,因为您没有等待它完成。由于您的
logOut
是async
,因此在调用它时需要使用wait
:
await authentication.logOut();
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LoginSignupToggle(true)), (route) => false);
这回答了你的问题吗?不,这对我来说没用,我更新了我的问题,你能再看一次吗?