Firebase authStateChanges() 不会在 Flutter 热重载时触发,但会在浏览器刷新时触发

时间:2021-06-27 00:49:21

标签: firebase-authentication

通过这种方法使用 Google 提供程序,以便我可以检测登录/退出并将用户从登录页面重定向到不同的页面:

 FirebaseAuth.instance.authStateChanges().listen()

现在我已经设置好用户状态,直到浏览器关闭:

FirebaseAuth.instance.setPersistence(Persistence.LOCAL);

不幸的是,当我从主页(主页是登录页面)使用 Google 提供程序时,Flutter 热重载不会触发 authstatechanges()。使用 F5 手动刷新浏览器似乎确实触发了该方法(假设它强制它读取 cookie)并按其应该重定向。

有没有办法手动触发 authstatechange(),因为 google provider 登录屏幕在热重载时不会要求提供凭据,但它确实会触发 firebase authstatechanges()。

0 个答案:

没有答案
相关问题