Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flatter firebaseauth注销()不工作_Firebase_Flutter_Dart_Firebase Authentication - Fatal编程技术网

Flatter firebaseauth注销()不工作

Flatter firebaseauth注销()不工作,firebase,flutter,dart,firebase-authentication,Firebase,Flutter,Dart,Firebase Authentication,我正在使用firebase auth注销方法,但它似乎工作不正常。当我点击注销按钮时,它应该将当前用户注销。但是,执行此操作后,控制台不会指示firebase auth注销方法实际正在工作,无 应用程序有一个系统,如果用户在线,则在打开应用程序时,他们将始终被重定向到主页,除非他们从应用程序注销(他们将被重定向到登录页面)。当打开应用程序时,应用程序总是将我重定向到主页,因此很明显,即使在我按下注销按钮后,firebase auth注销方法也不起作用 Authentication authent

我正在使用firebase auth注销方法,但它似乎工作不正常。当我点击注销按钮时,它应该将当前用户注销。但是,执行此操作后,控制台不会指示firebase auth注销方法实际正在工作,无

应用程序有一个系统,如果用户在线,则在打开应用程序时,他们将始终被重定向到主页,除非他们从应用程序注销(他们将被重定向到登录页面)。当打开应用程序时,应用程序总是将我重定向到主页,因此很明显,即使在我按下注销按钮后,firebase auth注销方法也不起作用

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);

这回答了你的问题吗?不,这对我来说没用,我更新了我的问题,你能再看一次吗?