avoid-keywords-in-wildcard-pattern
preset: recommended
Warns when a wildcard pattern has declaration keywords.
Example
❌ Bad:
void fn() {
final animal = 'hello';
final value = switch (animal) {
final Object? _ => 'bad', // LINT
var _ => 'bad', // LINT
final _ => 'bad', // LINT
};
}
✅ Good:
void fn() {
final animal = 'hello';
final value = switch (animal) {
Object? _ => 'good',
_ => 'good',
Object _ => 'good',
};
}