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:
m1({a}) {
assert(a != null);
}
GOOD:
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:
linter:
rules:
- always_require_non_null_named_parameters
Unless stated otherwise, the documentation on this site reflects Dart 3.5.3. Page last updated on 2024-07-03. View source or report an issue.