-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[share]: make Share an instantiable object #2818
Comments
I personally don't see the advantage. My approach with all 3rd party code, specially when it talks to platform implementations, is to always wrap it in a service class or similar you 100% control. That way, I don't have to worry about static methods, singletons, etc. or possible api changes. Looking at the other plugins implementations, some allow instances (like At the end of the day, all of them use an internal static singleton, with a factory constructor, e.g. plus_plugins/packages/connectivity_plus/connectivity_plus/lib/connectivity_plus.dart Lines 24 to 27 in 58596ac
So you may have multiple instances, at the end it is the same singleton. I'll be open to discuss further, but I don't think it is a priority for us to make this breaking change. |
I'm not sure what makes you think I'm not already doing that. However, if I want to test the wrapper, I need to pass each static function in the constructor, which is less convenient than just passing an object. Singletons are also an anti pattern.
This is just a "would have been nice to have" for me, no biggie. |
Sure, but we are talking about a plugin that talks to a platform implementation, not a typical OOP use-case. At the end, the plugin implementation uses a singleton internally. Something that we could do, is to make all plugins accessible via a This is something that could be done with the upcoming |
FYI, this is now being done in #3404 |
Plugin
share_plus
Use case
Currently every method on share are static but they do not need to be. This is less convenient for testing and ioc.
Proposal
Make
Share
a real object by having its method as instance methods.The text was updated successfully, but these errors were encountered: