-
-
Notifications
You must be signed in to change notification settings - Fork 514
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
Provider.disposable() Feature Request #108
Comments
Out of curiosity, why does your example takes a |
Note that this is not possible to do on So we can't do The only way would be to have a |
It takes
|
I'm mixed about that. Since there's no implicit interface implementation in Dart, our Considering the simplicity of the provider, I'd recommend making your own by subclassing |
I am already using my custom provider. But I'm forced to copy this Provider on each of my projects. |
@DenisBogatirov This is why, "Named constructors cannot have different generic constraints from the other constructors." |
An alternative is a static method: class Provider<T> {
static disposable<T extends Disposable>({ValueBuilder<T> builder}) {
return Provider(builder: builder, dispose: (_, d) => d.dispose());
}
} If that feature is truly desired, I encourage peoples to 👍 the issue. |
Unless the official Dart sdk includes a An alternative would be for dart to add static extension methods, or for you to make a custom |
It would be greate to have
Provider.disposable<T>
factory, whereT
implementsDisposable
It is very usefull in pair with
BLoC
pattern, you just overridedispose
method for each bloc and then use.The text was updated successfully, but these errors were encountered: