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。 檢視原始碼 或 報告問題。