Reputation:
I am using freezed with json generator. i am facing this error on generating the code.
Could not generate
fromJson
code forimages
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
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