-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
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
Not clear how to apply custom json serializable converter #240
Comments
The decorator isn't placed on the @freezed
abstract class Another with _$Another {
const factory Another({
@ModelConverter Model model,
}) = _Another;
factory Anotherl.fromJson(Map<String, dynamic> json) => _$AnotherFromJson(json);
} |
I see, now it works. Thanks. I was having doubts because the @freezed
abstract class Another with _$Another {
const factory Another({
// Adding the decorator with a list works as well!
@ModelConverter List<Model> modelList,
}) = _Another;
factory Another.fromJson(Map<String, dynamic> json) => _$AnotherFromJson(json);
} Do you think it would be useful to add this example to the docs (both for the plain |
Sure, feel free to make a PR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to apply my custom json converter. The README states that it is possible to add a custom json serializable converter to a model created with freezed, but it does not seem to provide an example on how to actually apply it to a model.
I tried different strategies, but all seem unsuccessful.
As stated, none of this solutions seem to work.
How can I apply my custom converter such that
toJson
andfromJson
generated with json_serializable utilize my custom converter?The text was updated successfully, but these errors were encountered: