I use Firebase Authentication for my app.
I can log / register correctly except when another user was log previously.
Exemple :
I am log, and I want to signout. Like this :
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
signOut() async {
await _firebaseAuth.signOut();
}
IconButton(
onPressed: () {
signOut();
Navigator.of(context, rootNavigator: true)
.pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
return const OnBoardingPage();
},
),
(_) => false,
);
},
icon: const Icon(Icons.logout))
So I came back to my onboarding page but I’m not fully disconnected.
I know it because I can display my email on the onboarding page (where normally no one can be connected)
So, I need to restart the app, and then, I am no longer connected and user mail can’t be displayed.
I think it is something about cache but not sure.
I want to know how to fully disconnected my account of my app. and avoid persistent session after logout.
3
Answers
Try
and in onPressed func
check the user currently signed in or not in splash screen
function to sign out
}
I’ve been having the same issue for quite some time and have tried various ways of correcting it, including the suggestions here and manually clearing all variables on sign-out. Hot reload persists the previous data but hot restart solves the issue. This issue persists in production too and is driving me nuts.
If you’re using shared preferences it might be worth you having a look at that is the only advice I can give right now. I am about to take a deep dive into this so will come back if and when I find anything.