implicit_call_tearoffs
Implicit tear-off of the 'call' method.
Description
#The analyzer produces this diagnostic when an object with a call
method is assigned to a function-typed variable, implicitly tearing off the call
method.
Example
#The following code produces this diagnostic because an instance of Callable
is passed to a function expecting a Function
:
dart
class Callable {
void call() {}
}
void callIt(void Function() f) {
f();
}
void f() {
callIt(Callable());
}
Common fixes
#Explicitly tear off the call
method:
dart
class Callable {
void call() {}
}
void callIt(void Function() f) {
f();
}
void f() {
callIt(Callable().call);
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.