Print a guide badge
Before you start this intermediate track
Typed functions and maps. The lessons use named parameters and nullable values.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
Named parameters make a function call describe its own choices. The badge function requires a name and offers a role that defaults to guest. Curly braces declare the named parameter, and role: supplies it at the call site. String interpolation then places both values into the badge text.
String badge(String name, {String role = 'guest'}) { return '$name [$role]';}void main() { final text = badge('Mina', role: 'guide'); print(text);}Each mission is a complete Dart 3 program with its own main function. Run one at a time with dart run. Only the built-in dart:core library is used; Flutter is not required.
Track the values line by line. Predict the result before running this example in your own editor.