Skip to main content

extend-equatable

added in: 1.2.0
⚙️

Warns when a class that matches the config does not extend Equatable.

note

This rule requires configuration in order to highlight any issues.

⚙️ Config

Set class-name-pattern (default is none) to configure the list of class names that need to extend Equatable.

Set file-name-pattern (default is none) to configure the list of file names with classes that need to extend Equatable.

dart_code_metrics:
...
rules:
...
- extend-equatable:
class-name-pattern: State$
file-name-pattern: '.model.dart'

Example

❌ Bad:

// LINT
class SomePerson {
const SomePerson(this.name);

final String name;
}

✅ Good:

class SomePerson extends Equatable {
const SomePerson(this.name);

final String name;


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