Mismatched value type in pattern assignment or declarationDRT-W1569
The analyzer produces this diagnostic when the type of the value on the right-hand side of a pattern assignment or pattern declaration doesn't match the type required by the pattern being used to match it.
Example
The following code produces this diagnostic because x might not be a
String and hence might not match the object pattern:
void f(Object x) {
var String(length: a) = x;
print(a);
}
Common fixes
Change the code so that the type of the expression on the right-hand side matches the type required by the pattern:
void f(String x) {
var String(length: a) = x;
print(a);
}