unnecessary_ wildcard_ pattern
Details about the 'unnecessary_wildcard_pattern' diagnostic produced by the Dart analyzer.
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:
void f(Object? x) {
if (x case _ && 0) {}
}
Common fixes
#Remove the use of the wildcard pattern:
void f(Object? x) {
if (x case 0) {}
}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.