Search code examples
firebaseflutterfirebase-authenticationflutter-bottomnavigation

Flutter Firebase Authentication Signout activity


On user signout, how to detect signout activity and reload botton navigation bar and pages in flutter with firebase authentication?


Solution

  • I will have to point you to FirebaseAuth.instance.onAuthStateChanged and StreamBuilder. FirebaseAuth.instance.onAuthStateChanged is a stream and will update when the user logs out.

    StreamBuilder<FirebaseUser>(
      stream: FirebaseAuth.instance.onAuthStateChanged,
      builder: (BuildContext context, snapshot) {
        if (snapshot.hasData) {
          return LoggedInWidget()
        } else {
          return LoggedOutWidget();
        }
      },
    )