-
Notifications
You must be signed in to change notification settings - Fork 1.7k
opt-out for old-school mixin-like classes from prefer_mixin #45343
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
Comments
If the annotation were to be used in the SDK it would need to be defined in the SDK, so I'll cc a couple more people: @leafpetersen @lrhn. |
@lrhn should we consider making a plan to migrate SDK class mixins to mixin mixins? |
@leaf Absolutely. It's breaking because someone might be extending the existing class, and you can't The best solution we've come up with for that is to allow We just hoped we could avoid the So, let's do it. Allow With that in place, it should be a non-breaking change to switch a I'll file an issue: dart-lang/language#1529 |
See also #47437 |
Thanks everyone for the discussion. Now that the As a result, I don't think an opt-out would be worth it at this point. Any new code needing this functionality can use Any concerns about closing this? :) |
No concerns. The |
Flutter has some classes (like ChangeNotifier and WidgetsBindingObserver) where we tell developers that those can be extended, implemented, or mixed-in. However, the
prefer_mixin
lint is not happy when they are used as a mixin in awith
clause. Since those classes pre-date the introduction of actual mixins in Dart, it would be nice if they can be opted out from the lint, e.g. by annotating them with something like@legacyMixin
.The Dart SDK also has some of these legacy mixins that would benefit from such an annotation (example: IterableMixin) to avoid the
prefer_mixin
warning in the following code snippet:/cc @pq @Hixie @mit-mit @munificent @devoncarew
The text was updated successfully, but these errors were encountered: