Skip to content

[google_sign_in] allow developer to handle platform exception when user cancels google sign in flow #6098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

JigneshWorld
Copy link

@JigneshWorld JigneshWorld commented Feb 12, 2024

This PR will pass PlatformException for kSignInCanceledError to App Level to provide flexibility to handle those as per the requirement of the development team without hindering catching the error inside the plugin.

flutter/flutter#85785
Reference: flutter/flutter#85785 (comment)

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

await expectLater(
googleSignIn.signIn(),
throwsA(isA<PlatformException>().having(
(e) => e.code,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 info - test/google_sign_in_test.dart:155:16 - Missing type annotation. Try specifying the type 'PlatformException'. - always_specify_types

error is from Luci, you can add the datatype here for e to fix that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @piedcipher for this fix. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to help!

Linux repo_checks is failing because of:

 --packages-for-branch: running on branch "HEAD".
 Running for all packages that have diffs relative to "0a692590a8853c6b3ea7b8e5ef16d1b746b2d39a"
 
 Changed packages: google_sign_in/google_sign_in
 [0:00] Running for packages/google_sign_in/google_sign_in...
   No version change.
   Found NEXT; validating next version in the CHANGELOG.
 No version change found, but the change to this package could not be verified to be exempt
 from version changes according to repository policy.
 If this is a false positive, please comment in the PR to explain why the PR
 is exempt, and add (or ask your reviewer to add) the "override: no versioning needed" label.
 
 
 The following packages had errors:
   packages/google_sign_in/google_sign_in:
     Missing version change
 See above for full details.

it seems a reviewer (part of the team) can fix it. congrats on your first pr!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @piedcipher for your support in getting this PR rolling 🎉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad I could, great work! 🙌🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference:

it seems a reviewer (part of the team) can fix it.

Per the error message, this would be true only for:

If this is a false positive, please comment in the PR to explain why the PR
is exempt

There is no such comment posted here (and it would be difficult for there to be, as this PR is not exempt for any of the reasons listed in the link from the PR checklist).

The actual fix for the CI failure here would be to complete the PR checklist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, got it!

@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution, but this is not a change we want to make to the plugin. The documented behavior is to return null for cancellation, and the fix for the referenced issue would be to make that happen correctly in all cases, not to make a breaking change to the interface to leak a PlatformException.

If you are interested in fixing the referenced issue, we'd be glad to review a PR that properly catches exceptions and returns null in the cases that are currently failing to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants