Skip to content

opt-out for old-school mixin-like classes from prefer_mixin #45343

Closed
@goderbauer

Description

@goderbauer

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 a with 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:

/// info: Prefer using mixins. (prefer_mixin)
abstract class Foo with IterableMixin<int> {
  // ...
}

/cc @pq @Hixie @mit-mit @munificent @devoncarew

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions