Ad

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);
}
Ad

Answer

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

Ad
source: stackoverflow.com
Ad