Optional Positional Parameter

  • Post author:
  • Post category:Dart
  • Post comments:2 Comments
Optional Positional Parameter

In this guide, we will discuss the Optional positional parameter in Dart Programming Language. 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 

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply