Skip to main content

prefer-equatable-mixin

effort: 2m
has IDE fix
teams+

Warns when a class extends Equatable instead of mixing in the EquatableMixin.

There is no upside in extending Equatable, but using the mixin allows you to also extend another class while keeping all equatable features.

Example

❌ Bad:

// LINT: The class should mix in 'EquatableMixin' instead of extending 'Equatable'.
class Person extends Equatable {
const Person(this.name);

final String name;


List<Object> get props => [name];
}

✅ Good:

class Person with EquatableMixin {
const Person(this.name);

final String name;


List<Object> get props => [name];
}