non_bool_operand工具 chevron_right診斷 chevron_rightnon_bool_operand 目錄描述示例常見修復方法運算子 '{0}' 的運算元必須可賦值給 'bool' 型別。描述#當 && 或 || 運算子的其中一個運算元不是 bool 型別時,分析器會生成此診斷。示例#以下程式碼會產生此診斷,因為 a 不是布林值dartint a = 3; bool b = a || a > 1;常見修復方法#將運算元更改為布林值dartint a = 3; bool b = a == 0 || a > 1;本頁面內容是否有幫助?thumb_up thumb_down感謝您的反饋! feedback 提供詳細資訊感謝您的反饋!請告訴我們如何改進。 bug_report 提供詳細資訊除非另有說明,本站點文件反映的是 Dart 3.8.1 版本。頁面最後更新於 2025-05-08。 檢視原始檔 或 報告問題。