json_serialized 插件不支持“文件”类型?

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\n
import \'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}\n
Run 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\n
Run Code Online (Sandbox Code Playgroud)\n\n

有人有主意吗?谢谢 !

\n

LgF*_*nco 4

JSON Schema 支持五种基本值类型:
- 字符串。
- 数字。
- 整数。
- 布尔值。
- 无效的。

您应该实现从字符串到文件的转换。