use_null_aware_elements工具 chevron_right诊断 chevron_rightuse_null_aware_elements 目录描述示例常见修复 toggle_on Lint 规则使用 null-aware 标记 '?',而不是通过 'if' 进行 null 检查。描述#当在集合字面量中使用了 null 检查而不是 null-aware 标记时,分析器会生成此诊断。示例#以下代码会生成此诊断,因为它使用 null 检查来决定是否应将 x 插入列表中,而 null-aware 标记 '?' 将会更简洁且不易出错。dartf(int? x) => [if (x != null) x];常见修复#用 null-aware 标记 '?' 替换 null 检查dartf(int? x) => [?x];此页面内容有帮助吗?thumb_up thumb_down感谢您的反馈! feedback 提供详情感谢您的反馈!请告诉我们如何改进。 bug_report 提供详情除非另有说明,本网站文档反映的是 Dart 3.8.1 版本。页面最后更新时间:2025-05-08。 查看源代码 或 报告问题。