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 forimages
because of typeAsset
.
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
Related Questions
- → I can't convert Json to string [OctoberCms]
- → Uncaught TypeError Illegal invocation when send FormData to ajax
- → Laravel Send URL with JSON
- → how to write react component to construct HTML DOM
- → AJAX folder path issue
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel - bindings file for repositories
- → Good solution to work with rest-api like SPA with redux?
- → getting the correct record in Angular with a json feed and passed data
- → Transformer usage on laravel/dingo API
- → Google options Page not saving - Javascript
- → Ember.js JSON API confusion
- → How can I query Firebase for an equalTo boolean parameter?
Ad