Parameter Passing Types — Dart
The two most basic kinds of argument are
Positional Arguments and
Named Arguments In this article we shall be discussing about the basic difference between these two argument types and the scenario of where to apply them.
- In Case of
Positional Argumentsthe order in which the data is being passed must not be changed [In our case (from below image) the first argument is of type
Stringand the next argument is of type
Doubleso in the function-call also we need to follow this order,
- And the next rule is, all arguments are required by default. [As we have defined
Doublein our function, both the values need to be passed during the function-call. No argument is optional unless specified].
Note: Differ by curly bracket in the Function Definition.
- In Case of
Named Argumentsthe order in which the data is being passed can be changed.
- And all the arguments are optional by default.(i.e., we can either pass the argument value or leave it empty unless it takes a null value).
👨💻Get the complete Source Code here 👉🏻: https://github.com/vijayinyoutube/dartarguments
Other articles you may like.,
If you want to know more about Flutter and various Widgets in Flutter…?🤓 Then visit my channel vijaycreations🚩