How to clear previous user cache data in Flutter Firebase?
688
You probably fixed this already but I was having the same issue and what worked for me was clearing app variables when loggin out.
I created a function to clear the variables and called it right before the signOut method
Comments
-
REVANTH N D over 1 year
I am facing a problem of whenever a user signs out
FirebaseAuth.instance.signOut()
and signs In with another account the previous user's data is visible. I have seen documentation and got an idea of clearing the cache data usingFirebaseFirestore.clearPersistence()
. I tried this in thesignOut
method but though previous user's data is still visible. Can anyone please solve my issue!main.dart
void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); FirebaseFirestore.instance.settings=Settings( persistenceEnabled: false, ); runApp(MyApp()); }
firebaseAuth.dart
static logOut()async{ await FirebaseFirestore.instance.clearPersistence(); return FirebaseAuth.instance.signOut(); }
THANK YOU SO MUCH!
-
ozkanpakdil about 3 yearscan you give code example for how to clear the app variables before signout?
-
Jairo R. Flores about 3 yearsThis works, but it seems weird that firebase been based on streams and a very accurate cache management by user, do this. Definitely the OP needs to give us more info on what was doing.
-
Dishank Jindal over 2 yearsCan you give more, as what you exactly did! because clearing variables seems easy but i am facing issues.