user16906111
user16906111

Reputation:

Could not generate `fromJson` code for `images` because of type `Asset`

I am using freezed with json generator. i am facing this error on generating the code.

Could not generate fromJson code for images because of type
Asset.

The Code Is:

abstract class ProductDTO with _$ProductDTO {
  factory ProductDTO({
    required String description,
    required List<Asset> images, // error
  }) = _ProductDTO;

  // from Json
  factory ProductDTO.fromJson(Map<String, dynamic> json) =>
      _$ProductDTOFromJson(json);
}

Upvotes: 5

Views: 7227

Answers (1)

Craig Labenz
Craig Labenz

Reputation: 2555

Custom data types require specific converters to handle their toJson and fromJson implementations. This question and its answers provide some nice examples.

Upvotes: 5

Related Questions