Skip to main content

no-equal-switch-case

added in: 1.1.0

Warns when a switch has cases with equal bodies.

Example

❌ Bad:

void main() {
final str = '123';

switch (str) {
case '1':
{
print('hello world');
break;
}

case '2':
{
print('same');
break;
}

// LINT
case '3':
{
print('same');
break;
}
}
}

✅ Good:

void main() {
final str = '123';

switch (str) {
case '1':
{
print('hello world');
break;
}

case '2':
{
print('same');
break;
}
}
}