Skip to content

fix(share_plus): share uri as URL on macOS so AirDrop is offered - #4024

Open
panfilov-vladislav wants to merge 1 commit into
fluttercommunity:mainfrom
panfilov-vladislav:fix/share-plus-macos-uri-url
Open

panfilov-vladislav wants to merge 1 commit into
fluttercommunity:mainfrom
panfilov-vladislav:fix/share-plus-macos-uri-url

Conversation

@panfilov-vladislav

Copy link
Copy Markdown

Description

On macOS, the uri argument of ShareParams was read as a String and passed to NSSharingServicePicker as-is. The picker chooses which services to offer from the type of the items, so a String is treated as plain text and link-aware services such as AirDrop were not listed. The paths branch already shares URLs; the uri branch did not, so uri behaved like text.

This PR converts uri to a URL before sharing, and falls back to the original String if it cannot be parsed as a URL, so existing behavior is kept for malformed input.

Tested with the share_plus example app on macOS 27.2.1 (Flutter 3.47.8), entering https://example.com/test in "Share uri":

  • Before this change: AirDrop is not listed in the share picker.
  • With this change: AirDrop is listed.

Related Issues

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 plugin version in 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.

On macOS the `uri` argument was read as a String and passed to
NSSharingServicePicker as-is. The picker offers services based on the
item type, so a String is treated as plain text and link-aware services
such as AirDrop were not listed.

Convert `uri` to a URL before sharing, as is already done for `paths`,
and fall back to the original String if it cannot be parsed.

Fixes fluttercommunity#4023
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.

[Bug]: macOS: uri is passed to NSSharingServicePicker as a String, so AirDrop is not offered

1 participant