avoid_ types_ on_ closure_ parameters
Avoid annotating types for function expression parameters.
Details
#AVOID annotating types for function expression parameters.
Annotating types for function expression parameters is usually unnecessary because the parameter types can almost always be inferred from the context, thus making the practice redundant.
BAD:
var names = people.map((Person person) => person.name);
GOOD:
var names = people.map((person) => person.name);
Incompatible rules
#The avoid_types_on_closure_parameters
lint is incompatible with the following rules:
Enable
#
To enable the
avoid_types_on_closure_parameters
rule, add
avoid_types_on_closure_parameters
under
linter > rules
in your
analysis_options.yaml
file:
linter:
rules:
- avoid_types_on_closure_parameters
If you're instead using the YAML map syntax to configure linter rules,
add
avoid_types_on_closure_parameters: true
under
linter > rules:
linter:
rules:
avoid_types_on_closure_parameters: true
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Report an issue.