prefer_mixin
Prefer using mixins.
This rule is available as of Dart 2.1.
Details
#Dart 2.1 introduced a new syntax for mixins that provides a safe way for a mixin to invoke inherited members using super
. The new style of mixins should always be used for types that are to be mixed in. As a result, this lint will flag any uses of a class in a with
clause.
BAD:
class A {}
class B extends Object with A {}
OK:
mixin M {}
class C with M {}
Usage
#To enable the prefer_mixin
rule, add prefer_mixin
under linter > rules in your analysis_options.yaml
file:
linter:
rules:
- prefer_mixin
Unless stated otherwise, the documentation on this site reflects Dart 3.5.3. Page last updated on 2024-07-03. View source or report an issue.