Does firebase store current user data automatically on phone in flutter?

137

Firebase Authentication SDKs store the credentials of the user in local storage, and then restore the user from there when the app restarts/page reloads.

Note that this doesn't always means that currentUser != null will work on app startup/page load, as restoring the credentials requires an asynchronous call to the server and currentUser will be null until that call completes. For the best results listen/respond to authStateChanges as shown in the documentation on authentication state.

Share:
137
Riyazat Durrani
Author by

Riyazat Durrani

I do programming as a hobby.

Updated on December 30, 2022

Comments

  • Riyazat Durrani
    Riyazat Durrani over 1 year

    I just saw a tutorial, where the author although was using shared-ref to store the user name, email etc locally, but he didn't use anything to store currentUser on a flutter app, which was connected to firebase. and hence in splash screen, he used if currentUser != null, then goto Home Screen, and it worked fine on restarting the app. hence to log out, again he used firebaseAuth.signOut() . so, does firebase stores currentUser automatically on the local storage of the app?

  • Riyazat Durrani
    Riyazat Durrani over 2 years
    I guess, the issue you are talking about is related to caching, turns out that indeed its stored locally, as stated by the accepted answer here. stackoverflow.com/questions/64042555/…