Dart Programming - Defining a Function



A function definition specifies what and how a specific task would be done. Before using a function, it must be defined. The syntax for defining a standard function is given below −

Syntax

function_name() {  
   //statements      
}

OR

void function_name() { 
   //statements 
}

The void keyword indicates that the function does not return any value to the caller.

Simple Function Definition

Example

test() { 
   //function definition 
   print("function called"); 
}

void main() { 
   // call the Function
   test();
} 

Output

It will produce the following output

function called
dart_programming_functions.htm
Advertisements