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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/share_plus/share_plus/lib/src/share_plus_linux.dart
Expand Up @@ -40,11 +40,7 @@ class SharePlusLinuxPlugin extends SharePlatform {
.join('&'),
);

if (await urlLauncher.canLaunch(uri.toString())) {
await urlLauncher.launchUrl(uri.toString(), const LaunchOptions());
} 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.

}

/// Share files.
Expand Down