在注册应用程序时,如何检查用户是否已在Firebase Auth中登录?

时间:2020-08-25 19:45:11

标签: flutter firebase-authentication

我想根据主题以及用户是否登录来更改状态栏的颜色。

在我的应用中,有多个注册页面,例如登录,确认电话号码,获取用户信息等。

在这些页面中,我想检查用户是否已成功注册,然后执行其他操作。这是相同的代码段。

FirebaseAuth.instance.currentUser().then((firebaseUser) {
    if (firebaseUser == null) {
    // signed out
    SystemChrome.setSystemUIOverlayStyle(
      isThemeLight
          ? SystemUiOverlayStyle.dark.copyWith(
              statusBarColor: Colors.transparent,
            )
          : SystemUiOverlayStyle.light.copyWith(
              statusBarColor: Colors.transparent,
            ),
    );
  } else {
    // signed in
    SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle.light.copyWith(
        statusBarColor: Colors.transparent,
      ),
    );
  }
});

但是在注册过程中firebaseUser == null是错误的,因此我进入else块。

应该发生的是,在注册过程完成之前,它应该留在if块中。我找不到解决此问题的方法。

任何帮助都会很棒。感谢您的宝贵时间!

1 个答案:

答案 0 :(得分:0)

您需要做的就是听greo -Eo,这是您的操作方式:

Release note for version 1.1.1:
相关问题