Calling a Dart Function
Calling a Dart Function
Calling a Dart Function is simple. After creating a function, we can call or invoke the defined function inside the main() function. A function is called using the function name and a parameter list. Parameters are also known as arguments. Note that the function parameters are optional.
Calling a Dart Function
The general syntax for calling a Dart function is as follows:
function_name(parameter_list);
variable=function_name(function arguments);
When we call a function, the program control is transferred to the called function. Then the called function executes the function body and returns the result to the calling function.
Example
Let’s take an example.
sum = add(10,20);
For example, if the main() function calls the add() function. The control is transferred to the add() function. The add() function is executed and returns the value to the caller function. The control returns to the main() function. The caller function can use the return value of the function by assigning the call to a variable.
—
Dart Tutorials
Dart tutorial on this website can be found at:
https://www.testingdocs.com/dart-tutorials-for-beginners/
More information on Dart: