extend-equatable
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
.
analysis_options.yaml
dart_code_metrics:
rules:
- extend-equatable:
class-name-pattern: State$
file-name-pattern: '.model.dart'
Example
❌ Bad:
// LINT: This class is expected to extend 'Equatable' as its name matches 'State$'
class SomeState {
const SomeState(this.name);
final String name;
}
✅ Good:
class SomeState extends Equatable {
const SomeState(this.name);
final String name;
List<Object> get props => [name];
}