Pass Future-returning fn as param in Dart: `fnName(param1, param2, (param3) => doSomethingReturningFuture())`

I’m trying to pass a function that returns Future<Response> as a parameter of a method.

I tried with the following code:

Future<String> _execute(Function<Future<Response>>() function) async { }

However, it does not compile. What is the correct syntax?

The correct syntax would be:

Future<String> _execute(Future<Response> Function() function) async { }

This allows you to pass in a function that returns a Future<Response> without any issues.