In this guide, we will discuss Optional Parameters with Default Values. Function parameters can also be assigned values by default. However, such parameters can also be explicitly passed values.
Syntax
function_name(param1,{param2= default_value}) { //...... }
Example
void main() { test_param(123); } void test_param(n1,{s1:12}) { print(n1); print(s1); }
It should return the following output−
123 12
Note − All required parameters in a function must occur before optional parameters.
Next Topic : Click Here
Pingback: Optional Named Parameter | Adglob Infosystem Pvt Ltd
Pingback: Dart Programming - Functions | Adglob Infosystem Pvt Ltd