目录

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