prefer-equatable-mixin
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];
}