-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
refactor(share_plus)!: Share API cleanup #2832
Conversation
if (isWithResult && !manager.setCallback(result)) return | ||
if (isWithResult) | ||
manager.setCallback(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is part of the change that fixes any possible deadlocks, since setCallback
will force any pending call to be returned with an "unavailable" ShareResult
callback.error( | ||
"Share callback error", | ||
"prior share-sheet did not call back, did you await it? Maybe use non-result variant", | ||
null, | ||
) | ||
false | ||
// Ensure no deadlocks. | ||
// Return result of any waiting call. | ||
// e.g. user called to `share` but did not await for result. | ||
this.callback?.success(RESULT_UNAVAILABLE) | ||
|
||
// Prepare all state for new share | ||
SharePlusPendingIntent.result = "" | ||
isCalledBack.set(false) | ||
this.callback = callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of failing with an error, the call to share
that is waiting for a response will get a ShareResult.unavailable
, and the new call would be properly registered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great one 👏🏻
Co-authored-by: Volodymyr Buberenko <vbuberen@users.noreply.github.com>
Co-authored-by: Volodymyr Buberenko <vbuberen@users.noreply.github.com>
Good! |
Description
This PR contains a major cleanup of the
share_plus
plugin.In detail:
shareUri
,share
andshareXFiles
(removed deprecated methods).ShareResult
.ShareSuccessManager
so it would not deadlock users anymore, instead, calling toshare
while there is another call waiting, causes that the previous call will be called back withShareResult.unavailable
, instead of causing an error.ShareResult
correctly returned.ShareResult
correctly.ShareResult.undefined
or throw an exception on error. Do not hide errors.Related Issues
Checklist
CHANGELOG.md
nor the plugin version inpubspec.yaml
files.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).