undefined_ method
Details about the 'undefined_method' diagnostic produced by the Dart analyzer.
The method '{0}' isn't defined for the '{1}' function type.
The method '{0}' isn't defined for the type '{1}'.
Description
#
The analyzer produces this diagnostic when a name is invoked without a
receiver inside a class, enum, mixin, extension, or extension type, and
it isn't defined by the enclosing declaration or in an enclosing scope.
An invocation with an instance receiver, such as x.foo(), reports
undefined_instance_member_read instead.
Example
#
The following code produces this diagnostic because C doesn't have a
member named removeMiddle:
class C {
void removeLast() {}
void f() {
removeMiddle();
}
}
Common fixes
#If the identifier isn't defined, then either define it or replace it with the name of a method that is defined. The example above can be corrected by fixing the spelling of the method:
class C {
void removeLast() {}
void f() {
removeLast();
}
}
Unless stated otherwise, the documentation on this site reflects Dart 3.13.3. Report an issue.