In this lesson, we will look at the different forms of creating parameters that are optional, namely positional and named. Optional positional arguments are useful when specifying a default value for a particular parameter. Optional named parameters are useful for specifying parameter defaults and writing self-documenting functions and methods.
Instructor: [00:00] Apart from parameters that are required, functions or methods in Dart can also specify optional parameters. These come in two flavors, positioning and named. The required parameters are listed first, followed by any of the optional parameters. Optional positional parameters are defined inside opening and closing square brackets, separated by commas.
[00:29] The exclaim parameter defaults to null. Let's specify a default Boolean, and add another parameter. Optional named parameters are defined inside opening and closing curly brackets.
[00:57] Using optional named parameters will help you define functions and methods that are self-documenting. Here's how you would use these in a case of methods. Let's invoke our method. Let's refactor our method example with named parameters, update the method call, run again.