Default parameter values

/// Sets the [bold] and [hidden] flags ... 
void enableFlags({bool bold = false, bool hidden = false}) 
// bold will be true; hidden will be false. 
enableFlags(bold: true);
string say(String from, String msg, [String device = 'carrier pigeon', String mood]) {...}
  • Your function can use = to define default values for both named and positional parameters.
  • The default values must be compile-time constants.
  • If no default value is provided, the default value is null.
  • You can also pass lists or maps as default values.

Default parameter values — Structure map

Clickable & Draggable!

Default parameter values — Related pages: