Functions: Optional Named Parameters


If the parameters are wrapped in curly braces, it means they are still optional, but they are now named parameters. The name is now required when calling the function.


examples/dart-intro/prompt_named.dart
String prompt(String text, {int count}) {
  if (count == null) {
    count = 1;
  }
  for (int i = 0; i < count; i++) {
    print(text);
  }
}

void main() {
    prompt("Your name:", count:3);
    prompt("Your Cat:");
}