Firebase Auth state check in Flutter

后端 未结 2 1431
栀梦
栀梦 2020-12-15 13:38

Currently I need to set up a check whether a user is logged in or not to then act accordingly (open home or log in screen). I\'m using only email authentication.

2条回答
  •  無奈伤痛
    2020-12-15 14:27

    What about

    FirebaseAuth.instance.onAuthStateChanged.listen((user) {
      setState(() => isAuthenticated = user != null);
    }) 
    

提交回复
热议问题