Skip to content

Conversation

vbuberen
Copy link
Collaborator

Description

In this PR I fixed issues with type in result.error(), which some users reported in #758. Saw that the code wasn't formatted according to our editorconfig file, which was added some time ago, so reformatted the code.

I didn't like that share_plus now has minSDK 23 as it cuts quite a lot of users/devices. I thought we could make it much lower, but it seems that 22 is the minimum possible, because Intent.createChooser() with sender parameter appeared only in SDK 22. So I made required changes to set minSDK to 22 and some additional small fixes.

Finally, I saw that in #788 there were changes to min Flutter version, but not all platforms were updated. Fixed it as well, so share_plus requires Flutter 1.20 on all platforms now.

Related Issues

Closes #758
Partially closes #789

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated the version in pubspec.yaml and CHANGELOG.md.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I am willing to follow-up on review comments in a timely manner.

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 a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@vbuberen vbuberen added the share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin label Mar 19, 2022
@vbuberen vbuberen requested a review from miquelbeltran March 19, 2022 15:18
@Mosc
Copy link

Mosc commented Mar 19, 2022

Not sure how these cases are generally handled, but I would prefer the minSdkVersion to go all the way back to 16 and simply return an appropriate result.error(...) for shareWithResult and shareFilesWithResult on SDK versions lower than 22. That would allow users to just continue to use share and shareFiles as they did before v4.0.0.

@Coronon
Copy link
Contributor

Coronon commented Mar 19, 2022

Not sure how these cases are generally handled, but I would prefer the minSdkVersion to go all the way back to 16 and simply return an appropriate result.error(...) for shareWithResult and shareFilesWithResult on SDK versions lower than 22. That would allow users to just continue to use share and shareFiles as they did before v4.0.0.

As said - I am pretty new to Android development. If that compiles and works as expected, it is probably the best option we have. The only risk I see there is people unintentionally using shareWithResult with a minSdkVersion lower than 16 and not noticing because their development environment is API level 22+. This could lead to users effected by unforeseen errors - can we somehow statically check this at compile time? And API version 22 is from 2015, so is this really necessary?

@Mosc
Copy link

Mosc commented Mar 19, 2022

Not sure how these cases are generally handled, but I would prefer the minSdkVersion to go all the way back to 16 and simply return an appropriate result.error(...) for shareWithResult and shareFilesWithResult on SDK versions lower than 22. That would allow users to just continue to use share and shareFiles as they did before v4.0.0.

As said - I am pretty new to Android development. If that compiles and works as expected, it is probably the best option we have. The only risk I see there is people unintentionally using shareWithResult with a minSdkVersion lower than 16 and not noticing because their development environment is API level 22+. This could lead to users effected by unforeseen errors - can we somehow statically check this at compile time? And API version 22 is from 2015, so is this really necessary?

I understand your concerns. A runtime error is certainly not ideal, although to be fair, shareWithResult and shareFilesWithResult already fail on runtime on web, Windows and Linux despite the package claiming those platforms are supported! We rely on the user reading the documentation for those specific methods.

How about falling back to the regular non-result based share operations and just returning ShareResultStatus.unavailable for Android SDKs under 22?

@vbuberen
Copy link
Collaborator Author

vbuberen commented Mar 19, 2022

How about falling back to the regular non-result based share operations and just returning ShareResultStatus.unavailable for Android SDKs under 22?

I agree that we should rework the solution with sharing with result. Not sure I can jump right into it (because I am an Android dev for quite some time and might be the right person to take care of it) as I am quite occupied with some activities here in Ukraine due to infamous events, so don't have much time. But let's see how it goes.

}
}
"shareWithResult" -> {
expectMapArguments(call)
Copy link
Contributor

@ekuleshov ekuleshov Mar 19, 2022

Choose a reason for hiding this comment

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

could these *withResults(..) methods extended with check like this?

if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
  result.notImplemented()
else ...

Then it won't be necessary to bump the minSdkVersion version for Android platform and it could be kept at the level supported in 3.x version of plugin.

Copy link
Member

Choose a reason for hiding this comment

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

I think so. If anyone can submit a separated PR with a that change, that would be awesome!

@Coronon
Copy link
Contributor

Coronon commented Mar 20, 2022

How about falling back to the regular non-result based share operations and just returning ShareResultStatus.unavailable for Android SDKs under 22?

That sounds like a good idea, as we already have that status and would not need to break any existing APIs as of version 4.0.1

I might even try to implement that tomorrow

PS: I am starting to grasp why Microsoft still supports DOS elements: People seem to hate to upgrade xD We should all adopt the “live at head” mentality abseil has… ^^

@ekuleshov
Copy link
Contributor

How about falling back to the regular non-result based share operations and just returning ShareResultStatus.unavailable for Android SDKs under 22?

Thank you for looking into this.

Now, if some platform would return ShareResultStatus.unavailable, perhaps it would be more consistent to do the same on web, linux and windows too instead of tossing not supported runtime exception on those?

@Coronon
Copy link
Contributor

Coronon commented Mar 20, 2022

I will fork this fork to base my PR on the better formatted code

@vbuberen
Copy link
Collaborator Author

I will fork this fork to base my PR on the better formatted code

I wouldn't bother yourself with that to depend on this PR, since I don't know for sure as to when it gets a review.

If it is just about formatting - auto formatting should work fine for you no matter which IDE you use as the project has an editorconfig file in its root, so code format should be forced according to riles in that file.

@Coronon
Copy link
Contributor

Coronon commented Mar 20, 2022

If it is just about formatting - auto formatting should work fine for you no matter which IDE you use as the project has an editorconfig file in its root, so code format should be forced according to riles in that file.

I only use melos format, which seems to not yield the same result as your formatting, but ok, will depend on the main branch then

@Coronon
Copy link
Contributor

Coronon commented Mar 20, 2022

Just pushed my changes, please try this example project with your low API version devices/emulators: https://github.com/Coronon/share_plus_result_example

I also added graceful fallback for other platforms to the normal share experience with ShareResult.unavailable being returned.
The documentation is also clearer now I hope.

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.

Thank you @vbuberen !

@vbuberen vbuberen merged commit a4a5218 into fluttercommunity:main Mar 21, 2022
@vbuberen vbuberen deleted the fix/share_plus_types branch March 21, 2022 07:53
@miquelbeltran
Copy link
Member

and published

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

share_plus Android minSdk bump drops support for a lot of devices [share_plus] Type mismatch: inferred type is String? but String was expected
5 participants