avoid-wildcard-cases-with-enums
preset: recommended
Warns when a switch on the Enum
value has a wildcard pattern case.
Example
❌ Bad:
enum MyEnum { first, second }
void someFn() {
final value = MyEnum.first;
final result = switch (value) {
MyEnum.first => 1,
_ => 2, // LINT
};
}
✅ Good:
enum MyEnum { first, second }
void someFn() {
final value = MyEnum.first;
final result = switch (value) {
MyEnum.first => 1,
MyEnum.second => 2,
};
}