no-equal-switch-case
preset: recommended
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: This switch statement already has a 'case' with the same body. Try combining these cases.
case '3':
{
print('same');
break;
}
}
}
✅ Good:
void main() {
final str = '123';
switch (str) {
case '1':
{
print('hello world');
break;
}
case '2':
{
print('same');
break;
}
}
}