unnecessary_null_aware_operator_on_extension_on_nullable
Unnecessary null aware operator on extension on a nullable type.
This rule is available as of Dart 2.18.
Details
#Avoid null aware operators for members defined in an extension on a nullable type.
BAD:
dart
extension E on int? {
int m() => 1;
}
f(int? i) => i?.m();
GOOD:
dart
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:
analysis_options.yaml
yaml
linter:
rules:
- unnecessary_null_aware_operator_on_extension_on_nullable
除非另有说明,文档之所提及适用于 Dart 3.5.4 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。