mixin_ class_ declaration_ with_ clause
Details about the 'mixin_class_declaration_with_clause' diagnostic produced by the Dart analyzer.
The class '{0}' can't be declared a mixin because it has a 'with' clause.
Description
#
The analyzer produces this diagnostic when a class with the mixin
modifier has a with clause. A mixin class declaration cannot have a
with clause because that implies it extends a class other than Object.
Example
#
The following code produces this diagnostic because the mixin class B
has a with clause:
mixin M {}
mixin class B with M {}
Common fixes
#If you want to use the class as a mixin, remove the with clause:
mixin M {}
mixin class B {}
If you need the class to have a with clause, then remove the mixin
modifier:
mixin M {}
class B with M {}
Unless stated otherwise, the documentation on this site reflects Dart 3.11.0. Report an issue.