invocation_ of_ extension_ without_ call
Details about the 'invocation_of_extension_without_call' diagnostic produced by the Dart analyzer.
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.
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.