avoid-incomplete-copy-with
preset: recommended
Checks if all the parameters from the default constructor are included in the copyWith
method.
Example
❌ Bad:
class Person {
const Person({
required this.name,
required this.surname,
});
final String name;
final String surname;
// LINT
Person copyWith({String? name}) {
return Person(
name: name ?? this.name,
surname: surname,
);
}
}
✅ Good:
class Person {
const Person({
required this.name,
required this.surname,
});
final String name;
final String surname;
Person copyWith({String? name, String? surname}) {
return Person(
name: name ?? this.name,
surname: surname ?? this.surname,
);
}
}