September 2019
Beginner
512 pages
12h 52m
English
In Dart, Function is a type, like String or num. This means that they can also be assigned to fields or local variables, or passed as parameters to other functions; consider the following example:
String sayHello() { return "Hello world!";}void main() { var sayHelloFunction = sayHello; // assigning the function // to the variable print(sayHelloFunction()); // prints Hello world!}
In this example, the sayHelloFunction variable stores the sayHello function itself and does not invoke it. Later on, we can invoke it by adding () to the variable name just as though it was a function.
The function return type can be omitted as well, so the Dart analyzer infers ...
Read now
Unlock full access