4

json_serializable プラグインを使用していますが、File for images では動作しないようです。「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

誰でもアイデアを得ましたか?ありがとう !

4

1 に答える 1