We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug toJson will not add if we use freezed. and show this warning
YourModel must provide a `toJson()` method which return a Map.
To Reproduce Steps to reproduce the behavior:
@freezed class FoodTagCreateModel with _$FoodTagCreateModel { const factory FoodTagCreateModel({ required String name, required String description, }) = _FoodTagCreateModel; factory FoodTagCreateModel.fromJson(Map<String, dynamic> json) => _$FoodTagCreateModelFromJson(json); }
@RestApi() abstract class CrudApi { factory CrudApi(Dio dio, {String? baseUrl}) = _CrudApi; @POST('/api/v1/my-model') Future<void> 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
Expected behavior If body is not Map force to add toJson() whether it has toJson() or not.
The text was updated successfully, but these errors were encountered:
.g.dart
@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.
Sorry, something went wrong.
Duplicate. Correct solution is:
freezed: runs_before: - json_serializable json_serializable: runs_before: - retrofit_generator
No branches or pull requests
Describe the bug
toJson will not add if we use freezed.
and show this warning
To Reproduce
Steps to reproduce the behavior:
Expected behavior
If body is not Map force to add toJson() whether it has toJson() or not.
The text was updated successfully, but these errors were encountered: