unnecessary_wildcard_pattern
Unnecessary wildcard pattern.
Description
#The analyzer produces this diagnostic when a wildcard pattern is used in either an and (&&
) pattern or an or (||
) pattern.
Example
#The following code produces this diagnostic because the wildcard pattern (_
) will always succeed, making it's use in an and pattern unnecessary:
dart
void f(Object? x) {
if (x case _ && 0) {}
}
Common fixes
#Remove the use of the wildcard pattern:
dart
void f(Object? x) {
if (x case 0) {}
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-06-23. View source or report an issue.