metadeck
10/4/2018 - 2:49 PM

Beginners Dart - Named Parameters

Beginners Dart - Named Parameters

int squareFeet({int width, int length}) {
  
  return width * length;
  
}

//Function that accepts a value and a named value.
void download(String file, {int port:80}) {

  print("download $file{} on port ${port}");

}

void main() {

  //Declaring named parameters.
  int footage = squareFeet(length: 10, width: 5);

  print("Footage is ${footage}");
  download("myFile");
  //declaring a single specified parameter.
  download("myFile2", port: 90); 

}