Her*_*inn 6 dart flutter json-serialization
我正在使用 json_serialized 插件,但它似乎不适用于图像文件。未生成“myclass.g.dart”。我对其他类型没有任何麻烦。\n( https://pub.dev/packages/json_serialized/versions/0.5.4#-readme-tab- )
\n\n这是我的代码:
\n\nimport \'dart:io\';\n\nimport \'package:flutter/material.dart\';\nimport \'package:json_annotation/json_annotation.dart\';\n\npart \'myclass.g.dart\';\n\n@JsonSerializable()\nclass MyClass {\n final String name;\n final List<File> photosFile;\n\n MyClass({\n @required this.name,\n @required this.photosFile,\n });\n\n\n factory MyClass.fromJson(Map<String, dynamic> json) => _$MyClassFromJson(json);\n Map<String, dynamic> toJson() => _$MyClassToJson(this);\n\n\n}\nRun Code Online (Sandbox Code Playgroud)\n\n这是错误:
\n\n[SEVERE] json_serializable:json_serializable on lib/model/myclass.dart (cached):\nError running JsonSerializableGenerator\nCould not generate `fromJson` code for `photosFile` because of type `File`.\nNone of the provided `TypeHelper` instances support the defined type.\npackage:mydomus_edl/model/myclass.dart:11:20\n \xe2\x95\xb7\n17 \xe2\x94\x82 final List<File> photosFile;\n \xe2\x94\x82 ^^^^^^^^^^\n \xe2\x95\xb5\n[SEVERE] Failed after 171ms\nRun Code Online (Sandbox Code Playgroud)\n\n有人有主意吗?谢谢 !
\n| 归档时间: |
|
| 查看次数: |
2133 次 |
| 最近记录: |