Open
Description
If you have code like the following:
typedef MyAPI = int Function(int a, int b);
class A {
int m(int a, int b) => a + b;
}
class B {
void m(MyAPI api) {
print(api(1, 2));
}
}
void main() {
var b = B();
var a = A();
b.m(a.m);
}
Say you are creating a package and have not added testing or actually called the last line above (b.m(a.m)
) anywhere. There is no way for you to know that the call will break.
If you have something like this:
typedef MyAPI = int Function(int a, int b);
abstract class Base {
MyAPI get m;
}
class BaseA extends Base {
@override
MyAPI get m => (a, b) => a + b;
}
class B {
void m(MyAPI api) {
print(api(1, 2));
}
}
void main() {
var b = B();
var a = BaseA();
b.m(a.m);
}
The code will also work but the declaration at BaseA
for m
is not the best for writing down.
I'd like to ask for function getters to be able to be written as actual functions since they would work the same way.