Flutter Firebase Authentication Signout activity

Issue

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();
    }
  },
)

Answered By – Edmore M Gonese Digolodollarz

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *