Skip to content

[Request]: share_plus refactor and cleanup #1099

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

Closed
miquelbeltran opened this issue Sep 27, 2022 · 16 comments
Closed

[Request]: share_plus refactor and cleanup #1099

miquelbeltran opened this issue Sep 27, 2022 · 16 comments
Labels
android enhancement New feature or request Hacktoberfest Issues taking part in Hacktoberfest ios iPadOs linux macos share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin web windows

Comments

@miquelbeltran
Copy link
Member

miquelbeltran commented Sep 27, 2022

Plugin

share_plus

Use case

Currently, share_plus is a bit messy:

  • 4 different methods that do somehow the same (share, shareFiles, shareWithResult, and shareFilesWithResult).
  • Sharing URLs, something that iOS and macOS support, is currently broken.

Proposal

The refactor should:

  • Unify all four methods into a single one.
  • Deprecate the old methods.
  • Remove code duplication
  • Add a way to share a URL on iOS (not as String, but as NSURL)
@miquelbeltran miquelbeltran added enhancement New feature or request triage Hackoberfest-Special share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin ios android macos web windows linux iPadOs and removed triage labels Sep 27, 2022
@miquelbeltran
Copy link
Member Author

Share files implementation for web to be done in another ticket: #212

@ueman
Copy link
Contributor

ueman commented Sep 27, 2022

Since file io isn't supported on web via dart:io it could make sense to use https://pub.dev/packages/cross_file in order to pass files to the share plugin.

@miquelbeltran
Copy link
Member Author

miquelbeltran commented Sep 27, 2022

@ueman note that the web implementation is discussed in #212

edit: oh sorry you already replied there

@mhadaily mhadaily added the Hacktoberfest Issues taking part in Hacktoberfest label Sep 28, 2022
@ThexXTURBOXx
Copy link
Contributor

I would happily take this issue on as part of Hacktoberfest, if possible and still free :)

@miquelbeltran
Copy link
Member Author

@ThexXTURBOXx details regarding hacktoberfest will be published soon, be sure to follow Majid on Twitter for more info: https://twitter.com/mhadaily ;)

@miquelbeltran
Copy link
Member Author

There's no ticket "reservation". Whoever gets the PR approved gets it.

@ThexXTURBOXx
Copy link
Contributor

Oh okay, I remembered last year when it worked like this. Sorry about that then!

@ThexXTURBOXx
Copy link
Contributor

I have developed a strategy on how to refactor the plugins. However, I still have two questions about this, because I am not sure which solution is desirable:

  • What should be the name of the unified method? Normally it would be called share, but this method already exists (as it is not deleted, but deprecated). I thought of shareObject or similar.
  • Should the platform interface and the platform-dependent implementations also be unified? I would have said that all share_plus related packages should be refactored, but if desired, I can also modify only the share_plus package and not the other packages.

Details of this are very welcome in order to achieve the desired refactoring.

@ueman
Copy link
Contributor

ueman commented Sep 30, 2022

  • What should be the name of the unified method? Normally it would be called share, but this method already exists (as it is not deleted, but deprecated). I thought of shareObject or similar.

You could create a ShareV2 class which would allow you to call the method just share. That would also make deprecation a bit easier, I guess.

@miquelbeltran
Copy link
Member Author

New class ShareV2 or new method shareV2 are both valid options indeed. Adding @Deprecated to the old methods then.

Should the platform interface and the platform-dependent implementations also be unified?

They will have to change as well, but we need to keep the federated plugin architecture, if that's what you mean.

(personally, I'd like to get rid of the federated plugin architecture, but that's out of scope for this ticket)

@ThexXTURBOXx
Copy link
Contributor

Alright, then I have the right picture on what needs to be done. Thank you very much for the detailed clarifications!

@ueman
Copy link
Contributor

ueman commented Oct 2, 2022

I would like to see the new 'share' method to take platform specific configuration objects.
Something like:

// pseudo code
ShareV2.share({
  String? content,
  String? subject,
  File? file,
  AndroidShareOptions? androidOptions,
  IosShareOptions? iosOptions,
}) {
  // implementation
}

The IosShareOptions could then be used to configure the origin for the share dialog on iPadOS for example. The AndroidShareOptions can be used to enable the Rich content previews of Android's share sheet.

That way the method parameters aren't cluttered with parameters and it's also clear which platforms have which options. It's probably also more future-proof.

local_auth does something similar for localizations.

@ghost
Copy link

ghost commented Oct 8, 2022

Is this issue fixed already?

@ThexXTURBOXx
Copy link
Contributor

No, not yet. If you want, you can do it :)

@ghost
Copy link

ghost commented Oct 8, 2022

Sure! I would love to. Can you help me a bit, like give me a quick rundown since I am a bit (Its not that I don't know the
language) new to Flutter and Dart?

@miquelbeltran miquelbeltran closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2022
@miquelbeltran
Copy link
Member Author

We won't be doing this at the moment, as we plan a general refactor of the plus plugins architecture.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
android enhancement New feature or request Hacktoberfest Issues taking part in Hacktoberfest ios iPadOs linux macos share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin web windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants