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

feat(share_plus): remove direct dependence of url_launcher #1295

Merged

Conversation

SirusCodes
Copy link
Contributor

@SirusCodes SirusCodes commented Oct 26, 2022

Description

Remove direct dependence of url_launcher, instead depending on platform specific packages.

Related Issues

resolves #1070

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.

@miquelbeltran
Copy link
Member

Is this PR still in progress?

@SirusCodes
Copy link
Contributor Author

Yes, I just need to fix some test.

@SirusCodes SirusCodes marked this pull request as ready for review October 28, 2022 10:12
Copy link
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

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

I like the idea. I don't fully understand why it was a problem to have url_launcher as a dependency originally, but I like that now it is injected as param, easier to mock or replace even.

@miquelbeltran
Copy link
Member

I will have to test on Monday before merging

@miquelbeltran miquelbeltran added Hacktoberfest Issues taking part in Hacktoberfest hacktoberfest-accepted labels Oct 29, 2022
@SirusCodes
Copy link
Contributor Author

I don't fully understand why it was a problem to have url_launcher as a dependency originally

Someone wanted to save a few KBs in their app, so why not.

@miquelbeltran miquelbeltran merged commit 055a19b into fluttercommunity:main Oct 31, 2022
@miquelbeltran
Copy link
Member

Thanks!

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

Choose a reason for hiding this comment

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

FYI: changing to this construction will break functionality, and has no advantages; see https://pub.dev/packages/url_launcher#checking-supported-schemes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, it's better to have only launchUrl in try catch block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking the return of launchUrl is better construct?

Choose a reason for hiding this comment

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

So, it's better to have only launchUrl in try catch block?

I'm not sure what the goal of a try/catch would be given that you are currently throwing.

Checking the return of launchUrl is better construct?

If you don't have a specific need to know in advance of trying (which is rare, and certainly isn't the case given the code here), checking what actually happened is better than using a potentially inaccurate prediction of what might happen, yes.

Copy link
Member

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.

If anyone can send a PR with the fix, I can review and merge asap

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 I can do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest Issues taking part in Hacktoberfest hacktoberfest-accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request]: share_plus android remove url_launcher
4 participants