Skip to content
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

fix(share_plus): remove canLaunch check #1315

Merged
merged 7 commits into from Nov 7, 2022

Conversation

SirusCodes
Copy link
Contributor

@SirusCodes SirusCodes commented Nov 1, 2022

Description

Reverting back to old construct as @stuartmorgan suggested #1295 (comment)

Also remove canLaunch check.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

} else {
throw Exception('Unable to share on web');
}
await urlLauncher.launchUrl(uri.toString(), const LaunchOptions());

Choose a reason for hiding this comment

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

Is it intentional that you are ignoring a false return here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just reverted it back. Initially it was not returning anything. Also, the API is not returning anything to the user.

Choose a reason for hiding this comment

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

Also, the API is not returning anything to the user.

But per the docs for launchUrl:

/// Returns true if the URL was launched successful, otherwise either returns
/// false or throws a [PlatformException] depending on the failure.

Is having share throw an exception for some failures, but failing completely silently for other failures, really the desired behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

For what I can see, we can check the result and throw an exception if it was false.

I think using a plain Exception would be fine here. I will push the changes.

@stuartmorgan
Copy link

Why only Linux? Other implementations were using the same construction.

@SirusCodes
Copy link
Contributor Author

Why only Linux? Other implementations were using the same construction.

Ahh... missed it. Thought it was only used in Linux. Will change them as well.

@SirusCodes SirusCodes changed the title fix(share_plus): revert to the older contruct for linux fix(share_plus): remove canLaunch check Nov 1, 2022
@@ -19,7 +19,6 @@ class SharePlusLinuxPlugin extends SharePlatform {
}

/// Share text.
/// Throws a [PlatformException] if `mailto:` scheme cannot be handled.
Copy link
Member

Choose a reason for hiding this comment

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

Removed for consistency with the other platforms

Comment on lines 46 to 47
if (!launchResult) {
throw Exception('Failed to launch mailto: URI');
Copy link
Member

Choose a reason for hiding this comment

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

As commented, the launchUrl can either return false or fail with an exception, in the case of returning false we throw an Exception.

I did not use PlatformException here because I don't think we should be creating them outside platform code, so I think just a generic Exception is fine here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it makes sense.

@SirusCodes
Copy link
Contributor Author

@miquelbeltran thanks for helping out. This feels fine to me

@miquelbeltran miquelbeltran requested review from stuartmorgan, nohli and vbuberen and removed request for stuartmorgan November 4, 2022 05:34
Copy link
Member

@nohli nohli left a comment

Choose a reason for hiding this comment

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

Looks good, just not sure if the thrown messages should include $uri instead of mailto: URI.

Copy link
Collaborator

@vbuberen vbuberen left a comment

Choose a reason for hiding this comment

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

LGTM

@miquelbeltran miquelbeltran merged commit f8f1a0b into fluttercommunity:main Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants