I'm trying to automatically route back to my menu screen after a successful login and I'm having trouble generating a Widget build and/or context. I'm doing this in a Stateless Widget. Here is my code. I would like to call route after the last print statement...
Future<Null> _handleSignIn() async {
try {
await _googleSignIn.disconnect();
GoogleSignInAccount googleUser = await _googleSignIn.signIn();
GoogleSignInAuthentication googleAuth = await googleUser.authentication;
print(googleAuth.idToken);
await FirebaseAuth.instance.signInWithGoogle(idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
} catch (error) {
print(error);
}
print("Let's Do This");
print(_googleSignIn.currentUser.displayName);
print(FirebaseAuth.instance.currentUser);
}
From what I understand from your question you basically need to setup your sign in button to redirect the users to wherever you want them to be after a successful sign in.
You can setup your onPressed call as follows, and you should be fine from here:
Note that you can not use Navigator outside your build method, hence you always need to handle the navigation parts within your widgets. Check the comment on this answer.