I'm trying to pass as parameter of a method, a function that returns Future<Response>
.
I tried to do
Future<String> _execute(Function<Future<Response>>() function) async { }
but it does not even compile.
What's the correct syntax?
You can do it like this,
Future<String> _myFunction(Future<Response> Function() function) {
...
}
You just need to specify that your parameter is a Function:
Future<bool> kappa() async{
await Future.delayed(Duration(seconds: 1));
return true;
}
Future<bool> foo(Function f) async{
var k = await f();
return k;
}
void main() async{
print(await foo(kappa));
}
This will print true
. In your case, your function parameter can be:
Future<String> _execute(Function function) async { }
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