Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我尝试在 Flutter 中使用 Freezzed 包构建对象时出现此错误
如果我尝试使用其他一些数据类型而不是 DateTime 我没有收到任何错误
如何解决这个问题?谢谢
发布规范.yaml
build_runner: ^2.0.4 freezed: ^0.14.2 json_serializable: ^4.1.3
颤振版本:2.2.1
导致该错误是因为DateTime.now()它永远const不会改变DateTime.now()此类(PracticalModel())实例化时的值。
DateTime.now()
const
PracticalModel()
尝试const从您的班级中删除
//... // remove const from here. factory PracticalModel({//...}) //...