mixin_ inherits_ from_ not_ object
The class '{0}' can't be used as a mixin because it extends a class other than 'Object'.
Description
#
The analyzer produces this diagnostic when a class that extends a class
other than Object is used as a mixin.
Example
#
The following code produces this diagnostic because the class B, which
extends A, is being used as a mixin by C:
//@dart=2.19
class A {}
class B extends A {}
class C with B {}
Common fixes
#
If the class being used as a mixin can be changed to extend Object, then
change it:
//@dart=2.19
class A {}
class B {}
class C with B {}
If the class being used as a mixin can't be changed and the class that's
using it extends Object, then extend the class being used as a mixin:
class A {}
class B extends A {}
class C extends B {}
If the class doesn't extend Object or if you want to be able to mix in
the behavior from B in other places, then create a real mixin:
class A {}
mixin M on A {}
class B extends A with M {}
class C extends A with M {}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.