So In my class constructor I want to accept a function as input so:
class foo() {
final Function inpFunc;
foo({this.inpFunc});
}
I want to only accept functions that return int but final Function<int> inpFunc is not valid
What should I do?
You can add return type and parameter details to be more specific.
int Function() for instance.
class Foo {
final int Function() inpFunc;
Foo(this.inpFunc);
}
main() {
var foo = Foo(() => 42);
print(foo.inpFunc());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With