0

I'm using flutter and firebase auth with google sign in. specifically I'm referring to this Tutorial

but, in that case no redirect after login success. in my case, i want to redirect after login success.

I have made like this on AuthService

Future<FirebaseUser> googleSignIn() async {
loading.add(true);
GoogleSignInAccount googleUser = await _googleSignIn.signIn();
GoogleSignInAuthentication googleAuth = await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
  accessToken: googleAuth.accessToken,
  idToken: googleAuth.idToken,
);
FirebaseUser user = await _auth.signInWithCredential(credential);
updateUserData(user);
print("signed in : " + user.displayName);
loading.add(false);
return user;
}

initState

void initState() {
super.initState();
authService.profile.listen((state) {
  print("ini statenya $state");
});
}

and button

CupertinoButton(
            color: const Color(0xFFdd4b39),
            child: const Text('Google'),
            onPressed: () => authService.googleSignIn().then((user) {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                        builder: (context) => BeforeDashboard(
                              uuid: user,
                            )),
                  );
                })),

But, it only work when i use debug mode. and not redirect on release mode. After choose account popup will be gone but not redirect on dashboard

faradie
  • 57
  • 8
  • Great! thats work. Thanks – faradie Mar 23 '19 at 03:28
  • you're welcome, just as a suggestion, when an answer or question is helpful, you may vote it up! cheers! – Feu Mar 23 '19 at 11:46
  • Sorry, i'm worng :( cause i forget running ap in debug mode. like i say in topic that only work when i use debug mode. and not redirect on release mode. – faradie Mar 23 '19 at 13:04
  • After a long struggle, this statement can help me [here](https://stackoverflow.com/a/49364521/11192681) Thanks – faradie Mar 27 '19 at 00:27
  • interesting, have you already [signed](https://flutter.dev/docs/deployment/android#signing-the-app) the app? – Feu Mar 27 '19 at 20:19
  • yes, i already to signed the app at preparation before release. – faradie Mar 28 '19 at 12:10

0 Answers0