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。 查看源文件 或 报告问题。