avoid_types_on_closure_parameters
Avoid annotating types for function expression parameters.
This rule is available as of Dart 2.0.
This rule has a quick fix available.
Incompatible rules: always_specify_types
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:
dart
var names = people.map((Person person) => person.name);
GOOD:
dart
var names = people.map((person) => person.name);
Usage
#To enable the avoid_types_on_closure_parameters
rule,
add avoid_types_on_closure_parameters
under linter > rules in your
analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- avoid_types_on_closure_parameters
除非另有说明,文档之所提及适用于 Dart 3.5.4 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。