Following the brilliant Firebase Flutter tutorial, I'm trying to incorporate Google sign-in into my app.
The flow: If not logged in, user will always arrive at login page (via checks at the MaterialApp
's onGenerateRoute
), user then presses the Login button and redirected to the Google sign-in flow. However, should the user cancel the flow midway, I'd like to return to the login page, forcing her to press the button again.
I fail to catch the PlatformException for some reason (you can see it in the debugger, and the app hanging in the simulator):
The code I'm using:
Future<bool> logIn() async {
print('Login::logIn()');
bool loggedIn = await logInSilently();
print('Login::logIn() - silent login returned $loggedIn');
if (loggedIn == false) {
try {
await googleSignIn.signIn();
} catch (e) {
print('Login::logIn() - interactive login failed: $e');
return false;
}
}
return true;
}
The print
statement inside the catch block is never printed, and the app hangs. I've upgraded flutter and re-tested before posting the question - the issue is still there.
(To clarify: The "happy path" -- i.e. user successfully going through the Google sign-in flow -- works.)
Step 1: First create the flutter project in your IDE. Step 2: After that just remove the default code and start from scratch. Step 3: Now just import the material library and call the runApp( ) function into the main function name as GoogleSignIn. Step 4: Now make a stateful widget with the name 'GoogleSignIn'.
PlatformException class Null safetyThrown to indicate that a platform interaction failed in the platform plugin.
I believe this was fixed in google_sign_in version 0.2.1.
Try putting changing your google_sign_in
dependency in your pubspec.yaml
to ^0.2.1
and see if that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With