Skip to content

[Request]: share_plus refactor and cleanup #1099

Description

@miquelbeltran

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)

Activity

  1. miquelbeltran commented on Sep 27, 2022

    @miquelbeltran
    MemberAuthor

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

  2. ueman commented on Sep 27, 2022

    @ueman
    Contributor

    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.

  3. miquelbeltran commented on Sep 27, 2022

    @miquelbeltran
    MemberAuthor

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

    edit: oh sorry you already replied there

  4. 1 remaining item

  5. ThexXTURBOXx commented on Sep 28, 2022

    @ThexXTURBOXx
    Contributor

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

  6. miquelbeltran commented on Sep 28, 2022

    @miquelbeltran
    MemberAuthor

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

  7. miquelbeltran commented on Sep 30, 2022

    @miquelbeltran
    MemberAuthor

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

  8. ThexXTURBOXx commented on Sep 30, 2022

    @ThexXTURBOXx
    Contributor

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

  9. ThexXTURBOXx commented on Sep 30, 2022

    @ThexXTURBOXx
    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.

  10. ueman commented on Sep 30, 2022

    @ueman
    Contributor
    • 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.

  11. miquelbeltran commented on Sep 30, 2022

    @miquelbeltran
    MemberAuthor

    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)

  12. ThexXTURBOXx commented on Sep 30, 2022

    @ThexXTURBOXx
    Contributor

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

  13. ueman commented on Oct 2, 2022

    @ueman
    Contributor

    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.

  14. ThexXTURBOXx commented on Oct 8, 2022

    @ThexXTURBOXx
    Contributor

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

  15. miquelbeltran commented on Oct 8, 2022

    @miquelbeltran
    MemberAuthor

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

  16. locked as resolved and limited conversation to collaborators on Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions