Stack Overflow Asked by Himanshu Ranjan on January 31, 2021
These are my login and logout functions using firebase auth in flutter,The sign is working perfectly but the signout is not working, I tried to print the ‘signout text’ in debug console and its printing but then the navigation to SignIn page part is not working.
Future<FirebaseUser> signInWithGoogle() async {
try{GoogleSignInAccount googleUser = await _googleSignIn.signIn();
// Step 2
GoogleSignInAuthentication googleAuth = await googleUser.authentication;
final AuthCredential cred= GoogleAuthProvider.getCredential(idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
FirebaseUser user = (await _auth.signInWithCredential(cred)).user;
return user;} catch(e){
print(e.toString());
return null;
}
}
signOutGoogle() async{
await _auth.signOut();
await _googleSignIn.signOut();
print('signed out');
}
This is my signout button implementation:
FlatButton.icon(
onPressed: () async => {
Navigator.pushNamed(context, '/signin'),
_auth.signOutGoogle(),
},
icon: Icon(Icons.exit_to_app),
label: Text(
'Sign out',
style: GoogleFonts.abel(color: Colors.black),
),
)
switch the 2 methods and await the signOutGoogle():
onPressed: () async {
await _auth.signOutGoogle(),
Navigator.pushNamed(context, '/signin'),
},
Answered by Scott Godfrey on January 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP