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:
void f(Object o) {
if (o case String(length: var length)) {
print('string is $length characters long');
}
}
Common fixes
#Remove the redundant member name:
void f(Object o) {
if (o case String(:var length)) {
print('string is $length characters long');
}
}
Unless stated otherwise, the documentation on this site reflects Dart 3.11.0. Report an issue.