enum_constant_with_non_const_constructor工具 chevron_right診斷 chevron_rightenum_constant_with_non_const_constructor 目錄描述示例常見修復方案呼叫的建構函式不是“const”建構函式。描述#當使用工廠建構函式或未標記為 const 的生成式建構函式建立列舉值時,分析器會生成此診斷資訊。示例#以下程式碼會生成此診斷資訊,因為列舉值 e 由工廠建構函式初始化dartenum E { e(); factory E() => e; }常見修復方案#使用標記為 const 的生成式建構函式dartenum E { e._(); factory E() => e; const E._(); }本頁面內容是否有幫助?thumb_up thumb_down感謝您的反饋! feedback 提供詳情感謝您的反饋!請告訴我們如何改進。 bug_report 提供詳情除非另有說明,本網站文件反映 Dart 3.8.1 版本。頁面最後更新於 2025-05-08。 檢視原始檔 或 報告問題。