Skip to main content

no_equal_then_else

Warns when "if"-"else" statements or ternary conditionals have identical if and else condition handlers.

Example

BAD:

final valueA = 'a';
final valueB = 'b';

if (condition) { // LINT
selectedValue = valueA;
} else {
selectedValue = valueA;
}

selectedValue = condition ? valueA : valueA; // LINT

GOOD:

final valueA = 'a';
final valueB = 'b';

if (condition) {
selectedValue = valueA;
} else {
selectedValue = valueB;
}

selectedValue = condition ? valueA : valueB;