list-all-equatable-fields
Warns when a field is not added to props
getter of a class that extends Equatable
or EquatableMixin
.
Example
❌ Bad:
class AnotherPerson extends Equatable {
const AnotherPerson(this.name, this.age);
final String name;
final int age;
List<Object> get props => [name]; // LINT: Missing declared class fields: age. Try adding them.
}
class AndAnotherPerson extends Equatable {
static final someProp = 'hello';
const AndAnotherPerson(this.name);
final String name;
List<Object> get props => [name];
}
class SubPerson extends AndAnotherPerson {
const SubPerson(this.value, String name) : super();
final int value;
List<Object> get props {
return super.props..addAll([]); // LINT: Missing declared class fields: value. Try adding them.
}
}
class EquatableDateTimeSubclass extends EquatableDateTime {
final int century;
EquatableDateTimeSubclass(
this.century,
int year, [
int month = 1,
int day = 1,
int hour = 0,
int minute = 0,
int second = 0,
int millisecond = 0,
int microsecond = 0,
]) : super(year, month, day, hour, minute, second, millisecond, microsecond);
List<Object> get props => super.props..addAll([]); // LINT: Missing declared class fields: century. Try adding them.
}
✅ Good:
class AnotherPerson extends Equatable {
const AnotherPerson(this.name, this.age);
final String name;
final int age;
List<Object> get props => [name, age];
}
class AndAnotherPerson extends Equatable {
static final someProp = 'hello';
const AndAnotherPerson(this.name);
final String name;
List<Object> get props => [name];
}
class SubPerson extends AndAnotherPerson {
const SubPerson(this.value, String name) : super();
final int value;
List<Object> get props {
return super.props..addAll([value]);
}
}
class EquatableDateTimeSubclass extends EquatableDateTime {
final int century;
EquatableDateTimeSubclass(
this.century,
int year, [
int month = 1,
int day = 1,
int hour = 0,
int minute = 0,
int second = 0,
int millisecond = 0,
int microsecond = 0,
]) : super(year, month, day, hour, minute, second, millisecond, microsecond);
List<Object> get props => super.props..addAll([century]);
}