always_require_non_null_named_parameters
Specify @required
on named parameters without defaults.
This rule has been removed as of the latest Dart releases.
Details
#NOTE: This rule is removed in Dart 3.3.0; it is no longer functional.
DO specify @required
on named parameters without a default value on which
an assert(param != null)
is done.
BAD:
dart
m1({a}) {
assert(a != null);
}
GOOD:
dart
m1({@required a}) {
assert(a != null);
}
m2({a: 1}) {
assert(a != null);
}
NOTE: Only asserts at the start of the bodies will be taken into account.
Usage
#To enable the always_require_non_null_named_parameters
rule,
add always_require_non_null_named_parameters
under linter > rules in your
analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- always_require_non_null_named_parameters
除非另有说明,文档之所提及适用于 Dart 3.5.3 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。