I was looking into the documentation and failed to find an answer to my question:
Suppose I have a function the returns a Future<String>
that I want to imbed in a second function which could take any other function that is of type Future<String>
, the syntax -if I am not wrong- would be:
String functionTwo(Future<User> Function() putFunctionHere) async {
await code
return 'some string';
}
If I had to guess with regards to Dart syntax, I would say that it would be:
String functionTwo(Function putFunctionHere){...}
Which leads me to my question, why do we have to specify Future<User> Function()
is it the only way?
And why do we have to put the parentheses next to Function