Skip to content

Commit

Permalink
Try to clarify optional parameter restrictions (#2621)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesderlin authored Sep 14, 2020
1 parent afdb8f5 commit 3846432
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/_guides/language/language-tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -1127,22 +1127,22 @@ is sometimes referred to as _arrow_ syntax.
there, but you can use a [conditional expression](#conditional-expressions).
{{site.alert.end}}

A function can have two types of parameters: _required_ and _optional_.
The required parameters are listed first, followed by any optional parameters.
Optional parameters can be _named_ or _positional_.
### Parameters

A function can have any number of *required positional* parameters. These can be
followed either by *named* parameters or by *optional positional* parameters
(but not both).

{{site.alert.note}}
Some APIs — notably [Flutter][] widget constructors — use only named
parameters, even for parameters that are mandatory. See the next section for
details.
{{site.alert.end}}

### Optional parameters

Optional parameters can be either named or positional, but not both.

#### Named parameters

Named parameters are optional unless they're specifically marked as required.

When calling a function, you can specify named parameters using
<code><em>paramName</em>: <em>value</em></code>. For example:

Expand Down Expand Up @@ -1179,7 +1179,11 @@ then the analyzer reports an issue.
To use the [@required][] annotation,
depend on the [meta][] package and import `package:meta/meta.dart`.

#### Positional parameters
{% comment %}
NULLSAFE: Rewrite this section.
{% endcomment %}

#### Optional positional parameters

Wrapping a set of function parameters in `[]` marks them as optional
positional parameters:
Expand Down

0 comments on commit 3846432

Please sign in to comment.