Optional Positional Parameter


Advertisements

To specify optional positional parameters, use square [] brackets.

Syntax

void function_name(param1, [optional_param_1, optional_param_2]) { } 

If an optional parameter is not passed a value, it is set to NULL.

Example

void main() { 
   test_param(123); 
}  
test_param(n1,[s1]) { 
   print(n1); 
   print(s1); 
} 

It should produce the following output

123 
null 
dart_programming_functions.htm
Advertisements