invocation_ of_ extension_ without_ call
The extension '{0}' doesn't define a 'call' method so the override can't be used in an invocation.
Description
#
The analyzer produces this diagnostic when an extension override is used to
invoke a function but the extension doesn't declare a call method.
Example
#
The following code produces this diagnostic because the extension E
doesn't define a call method:
extension E on String {}
void f() {
E('')();
}
Common fixes
#If the extension is intended to define a call method, then declare it:
extension E on String {
int call() => 0;
}
void f() {
E('')();
}
If the extended type defines a call method, then remove the extension
override.
If the call method isn't defined, then rewrite the code so that it
doesn't invoke the call method.
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.