DEV Community

Cover image for Dart 101: Parameter vs Argument
Nabil
Nabil

Posted on • Updated on

Dart 101: Parameter vs Argument

Parameter

A parameter is a placeholder for a function's potential input value. At the time of declaring a function its parameter/parameters is/are inscribed within its parentheses. If a function needs multiple parameters for multiple input values, the parameters need to be comma separated.

In the following code block we have declared a function named getFullName. Here, firstName and lastName are the parameters of getFullName function.

String getFullName(String firstName, String lastName) {
  return "Full Name: $firstName $lastName";
}
Enter fullscreen mode Exit fullscreen mode

Argument

An argument is the actual input which is passed down to a function when the function is called, and in that case the argument replaces the parameter.

In the following code block we have called the getFullName function and assigned its return value to myFullName variable. Here, myFirstName and mySecondName are arguments of the getFullName function.

void main() {
  const myFirstName = "Nabil";
  const mySecondName = "Mahmud";
  final myFullName = getFullName(myFirstName, mySecondName);
  print(myFullName);
}
Enter fullscreen mode Exit fullscreen mode

N.B. A parameter is an abstract or virtual thing, but an argument is a concrete or actual thing.

Top comments (0)