Skip to main content

avoid-misused-wildcard-pattern

added in: 1.7.0
Dart 3.0+

Warns when a wildcard pattern is used in the wrong context.

Example

❌ Bad:

void fn() {
final animal = 'hello';

if (animal.isEmpty case _) {} // LINT

final (Object _) = animal; // LINT

if (animal.isEmpty case bool() && _) {} // LINT
}

✅ Good:

void fn() {
final animal = 'hello';

if (animal.isEmpty case final isEmpty) {}

final (Object object) = animal;

if (animal.isEmpty case final bool isEmpty) {}
}