一、需求来源
新项目中生成模型的工具用的乱七八糟,不知道什么野路子。随想自己实现一个,方便后面代码重构。
典型问题如下:
dart
1、字段未做可空处理
String identifier;
或者
late String identifier;
2、fromJson 转换方法 cast 报警告
Results.fromJson 转换方法(Map<String, dynamic> json) {
supportedDevices = json['supportedDevices'].cast<String>();
}
3、其他一些有警告未处理代码
成果:
- 修复以上问题。
- 还支持 CopyWith 方法。
- 支持模型文件下载。
- 支持黑夜模式,护眼更佳。
二、运行效果

