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:
dart
extension E on String {}
void f() {
E('')();
}
Common fixes
#If the extension is intended to define a call
method, then declare it:
dart
extension E on String {
int call() => 0;
}
void f() {
E('')();
}
If the extended type defines a call
method, then remove the extension
override.
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。