unnecessary_null_checks
Unnecessary null
checks.
This rule is currently experimental and available as of Dart 2.12.0.
This rule has a quick fix available.
Details
#DON'T apply a null
check where a nullable value is accepted.
BAD:
dart
f(int? i) {}
m() {
int? j;
f(j!);
}
GOOD:
dart
f(int? i) {}
m() {
int? j;
f(j);
}
Usage
#To enable the unnecessary_null_checks
rule,
add unnecessary_null_checks
under linter > rules in your
analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- unnecessary_null_checks
除非另有说明,文档之所提及适用于 Dart 3.5.0 版本,本页面最后更新时间: 2024-09-22。 查看文档源码 或者 报告页面问题。