All Dart functions (objects which has a function type rather than an class/interface type) have a call
method.
The call
method has the same function type as the function itself, and it behaves exactly the same when you call it. You could even say that calling a function is implicitly calling its call
method.
And, not by coincidence, the specification actually does say that: If you write the function invocation e1(e2, e3)
, then the compiler checks if e1
has call
method, and if so converts it to the method invocation e1.call(e2, e3)
.
Other Dart objects may have a call
method too. It's just a normal method for interface types, but if class C
has a call method like int call(int x) => ...
, and c
has type C
, then c(e2, e3)
is also converted to c.call(e2, e3)
. It has to be a call
method, not just a call
getter returning a function.