Flutter json#u可序列化插件不';t支持';文件';类型?

Flutter json#u可序列化插件不';t支持';文件';类型?,flutter,dart,json-serialization,Flutter,Dart,Json Serialization,我使用的是json_serializable插件,但它似乎不适用于图像文件未生成myclass.g.dart。其他类型的我没有任何问题。 () 这是我的代码: import 'dart:io'; import 'package:flutter/material.dart'; import 'package:json_annotation/json_annotation.dart'; part 'myclass.g.dart'; @JsonSerializable() class MyCla

我使用的是json_serializable插件,但它似乎不适用于图像文件未生成myclass.g.dart。其他类型的我没有任何问题。 ()

这是我的代码:

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';

part 'myclass.g.dart';

@JsonSerializable()
class MyClass {
  final String name;
  final List<File> photosFile;

  MyClass({
    @required this.name,
    @required this.photosFile,
  });


  factory MyClass.fromJson(Map<String, dynamic> json) => _$MyClassFromJson(json);
  Map<String, dynamic> toJson() => _$MyClassToJson(this);


}
导入'dart:io';
进口“包装:颤振/材料.省道”;
导入“package:json_annotation/json_annotation.dart”;
“myclass.g.dart”部分;
@JsonSerializable()
类MyClass{
最后的字符串名;
最终清单文件;
我的班级({
@需要此名称,
@需要此.photos文件,
});
工厂MyClass.fromJson(映射json)=>u$MyClassFromJson(json);
映射到JSON()=>$MyClassToJson(这个);
}
这就是错误:

[SEVERE] json_serializable:json_serializable on lib/model/myclass.dart (cached):
Error running JsonSerializableGenerator
Could not generate `fromJson` code for `photosFile` because of type `File`.
None of the provided `TypeHelper` instances support the defined type.
package:mydomus_edl/model/myclass.dart:11:20
   ╷
17 │   final List<File> photosFile;
   │                    ^^^^^^^^^^
   ╵
[SEVERE] Failed after 171ms
[SEVERE]json_serializable:json_serializable on lib/model/myclass.dart(缓存):
运行JsonSerializableGenerator时出错
由于类型“File”,无法为“photofile”生成“fromJson”代码。
提供的'TypeHelper'实例都不支持定义的类型。
软件包:mydomus_edl/model/myclass.dart:11:20
╷
17│   最终清单文件;
│                    ^^^^^^^^^^
╵
[严重]171ms后失败

有人有主意吗?谢谢

JSON模式支持五种基本值类型:
-字符串。
-编号。
-整数。
-布尔值。
-空


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

谢谢!这就是我所做的,我用List替换List,只存储文件的路径,它也会这样做。。。祝你好运