avoid-constant-switches
Warns when a switch expression or statement has a constant expression.
Constant expressions in switches always evaluate to the same value and usually indicate a typo or a bug.
Example
❌ Bad:
void fn() {
// LINT: This expression is constant and will always evaluate to the same value.
// Try changing this expression.
final value = switch (Some._val) {
...
};
// LINT: This expression is constant and will always evaluate to the same value.
// Try changing this expression.
switch (_another) {
...
};
}
abstract final class Some {
static const _val = '1';
}
const _another = 10;
✅ Good:
void fn(int another) {
// Now a parameter
switch (another) {
...
};
}