Я использую плагин json_serializable, но он не работает с файлом для изображений. myclass.g.dart не генерируется. У меня нет проблем для других типов.
(https://pub.dev/packages/json_serializable/versions/0.5.4#-readme-tab-)
Это мой код:
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);
}
И это ошибка:
[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
Кто-нибудь получил идею? Спасибо!