目錄
目錄

Unnecessary null aware operator on extension on a nullable type.

This rule is available as of Dart 2.18.0.

Details

Avoid null aware operators for members defined in an extension on a nullable type.

BAD:

extension E on int? {
  int m() => 1;
}
f(int? i) => i?.m();

GOOD:

extension E on int? {
  int m() => 1;
}
f(int? i) => i.m();

Usage

To enable the unnecessary_null_aware_operator_on_extension_on_nullable rule, add unnecessary_null_aware_operator_on_extension_on_nullable under linter > rules in your analysis_options.yaml file:

linter:
  rules:
    - unnecessary_null_aware_operator_on_extension_on_nullable