simplify_variable_pattern
Details about the 'simplify_variable_pattern' diagnostic produced by the Dart analyzer.
The {0} identification '{1}:' is redundant and can be removed.
Description
#The analyzer produces this diagnostic when a variable pattern includes a redundant type member name.
Example
#The following code produces this diagnostic because the variable pattern includes a redundant getter name:
dart
void f(Object o) {
if (o case String(length: var length)) {
print('string is $length characters long');
}
}
Common fixes
#Remove the redundant member name:
dart
void f(Object o) {
if (o case String(:var length)) {
print('string is $length characters long');
}
}
Was this page's content helpful?
除非另有说明,文档之所提及适用于 Dart 3.11.0 版本报告页面问题.