non_bool_condition工具 chevron_right診斷 chevron_rightnon_bool_condition 目錄描述示例常見修復條件必須具有 'bool' 型別的靜態型別。描述#當條件(例如 `if` 或 `while` 迴圈)不具有 `bool` 靜態型別時,分析器會產生此診斷資訊。示例#以下程式碼會產生此診斷資訊,因為 `x` 的靜態型別為 `int`dartvoid f(int x) { if (x) { // ... } }常見修復#修改條件,使其產生布爾值dartvoid f(int x) { if (x == 0) { // ... } }此頁面內容有幫助嗎?thumb_up thumb_down感謝您的反饋! feedback 提供詳情感謝您的反饋!請告訴我們如何改進。 bug_report 提供詳情除非另有說明,本網站文件反映 Dart 3.8.1 版本。頁面最後更新於 2025-05-08。 檢視原始檔 或 報告問題。