class_used_as_mixin
The class '{0}' can't be used as a mixin because it's neither a mixin class nor a mixin.
Description
#The analyzer produces this diagnostic when a class that is neither a mixin class
nor a mixin
is used in a with
clause.
Example
#The following code produces this diagnostic because the class M
is being used as a mixin, but it isn't defined as a mixin class
:
class M {}
class C with M {}
Common fixes
#If the class can be a pure mixin, then change class
to mixin
:
mixin M {}
class C with M {}
If the class needs to be both a class and a mixin, then add mixin
:
mixin class M {}
class C with M {}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.