0

I need to know how can i pass data in dart like parameter

 main() { 
   buildbirdKey(1);
 }  

  buildbirdKey(int soundNumber) { 
   print(soundNumber); 
 } 

This is example which is working fine. But i need to send int 1 in value or a parameter some thing like this

 main() { 
   buildbirdKey(soundNumber: 1);
  }  

 buildbirdKey(int soundNumber) { 
   print(soundNumber); 
  } 

Its giving error of The named parameter 'soundNumber' isn't defined.

Umaiz Khan
  • 1,319
  • 3
  • 20
  • 66

1 Answers1

1

I suggest you to have a look at this answer and the dart language tour.

When defining a function, use {param1, param2, …} to specify named parameters:

/// Sets the [bold] and [hidden] flags ...
void enableFlags({bool bold, bool hidden}) {...}
Mattia
  • 5,909
  • 3
  • 26
  • 41