no-equal-conditions
preset: recommended
Warns when a if statement has duplicate conditions.
Duplicate conditions are usually a sign of a bug (another condition should be used instead) or just dead code that can be simply removed.
Example
❌ Bad:
void main() {
final value = 1;
if (value == 1) {
return value;
} else if (value == 2) {
return value;
// LINT: Avoid duplicate conditions in 'if/else if'. Try replacing the duplicate condition or removing it.
} else if (value == 1) {
return value;
}
}
✅ Good:
void main() {
final value = 1;
if (value == 1) {
return value;
} else if (value == 2) {
return value;
} else if (value == 3) {
return value;
}
}