fix(share_plus): reset stale share state and normalize path separators on Windows - #3966
Open
OmarAfifi-CSE wants to merge 2 commits into
Open
Conversation
… for WinRT on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves critical state leakage and file sharing issues in
share_plus_windows:State Leak Across Consecutive Invocations:
share_text_,share_subject_,share_uri_,share_title_,paths_, andmime_types_inSharePlusWindowsPluginwere only conditionally overwritten when the corresponding argument was present in the incoming method call. If a user previously shared text and subsequently initiated a file-only share (without text), the stale text from the previous share was retained and sent alongside the file. Similarly, sharing files previously would cause subsequent text-only shares to leak the previous files..reset()and.clear()) at the start ofHandleMethodCallbefore parsing new arguments, ensuring every share request executes with a clean, isolated state as originally intended.WinRT Path Separator Rejection:
File.path,Directory.systemTemp, or standard path packages frequently contain POSIX-style forward slashes (/). Windows RuntimeWindows.Storage.StorageFile.GetFileFromPathAsyncstrictly rejects forward slashes withHRESULT 0x80070057(E_INVALIDARG: "The specified path is invalid"), preventing files from being appended tostorage_items. This caused the Windows Share Broker dialog to fail with "Try that again. We couldn't show you all the ways you could share."L'/'withL'\\'usingstd::replaceprior to invokingGetFileFromPathAsync.Mandatory Title Fallback for File Shares:
DataPackagePropertySetis mandatory on Windows. When sharing files without explicit text, subject, or title,properties->put_Titlereceived an empty string, which can cause the Share Broker flyout to fail.Related Issues
Fixes file sharing failures on Windows 10/11 when using temporary or normalized Dart file paths, and resolves state leakage between consecutive share operations.
Checklist
CHANGELOG.mdnor the plugin version inpubspec.yamlfiles.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?
!in the title as explained in Conventional Commits).