type_ test_ with_ non_ type
The name '{0}' isn't a type and can't be used in an 'is' expression.
Description
#
The analyzer produces this diagnostic when the right-hand side of an
is
or
is!
test isn't a type.
Example
#The following code produces this diagnostic because the right-hand side is a parameter, not a type:
typedef B = int Function(int);
void f(Object a, B b) {
if (a is b) {
return;
}
}
Common fixes
#If you intended to use a type test, then replace the right-hand side with a type:
typedef B = int Function(int);
void f(Object a, B b) {
if (a is B) {
return;
}
}
If you intended to use a different kind of test, then change the test:
typedef B = int Function(int);
void f(Object a, B b) {
if (a == b) {
return;
}
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.