Open b14cknc0d3 opened 3 weeks ago
@freezed
class FoodTagCreateModel with _$FoodTagCreateModel {
const factory FoodTagCreateModel({
required String name,
required String description,
}) = _FoodTagCreateModel;
factory FoodTagCreateModel.fromJson(Map<String, dynamic> json) =>
_$FoodTagCreateModelFromJson(json);
@override
Map<String, dynamic> toJson() => toJson();
}
Temporary solution.
Duplicate. Correct solution is:
freezed:
runs_before:
- json_serializable
json_serializable:
runs_before:
- retrofit_generator
Describe the bug toJson will not add if we use freezed. and show this warning
To Reproduce Steps to reproduce the behavior:
create a model with freezed
}
@RestApi() abstract class CrudApi { factory CrudApi(Dio dio, {String? baseUrl}) = _CrudApi;
@POST('/api/v1/my-model') Future createAModel(@Body() MyModel body);
MyModel must provide a
toJson()
method which return a Map. It is programmer's responsibility to make sure the MyModel is properly serialized