parameters in dart/flutter with example…
In this article we will see different types of parameters.
Required parameters:
void add(int a, int b)
When you are using this type of brackets then you have to pass two variables. It means these are the two required parameters.
Optional parameters:
void add(int a, int b,[int c])
For this method we can skip the third argument it means if you are passing only two values it won’t give error and the third one will be null value
Optional and named parameters:
void add(int a, int b,{int c})
For this method the third parameter is the optional and named parameter. If you want to pass the value then it would be like
c:
In dart language there is no method overloading concept instead of that we use this concept.
Thanks for reading, if you like my article please applaud.