Made generator set field to the initial value if null #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello Kevin Moore, from all the serialization libraries for dart out there, yours was always my favorite. But for me, it was lacking 2 major features: an ignore annotation and keep initial values if the deserialized field is null. I created two branches in this fork which include these features. With them, it's all I wanted from a serialization library for dart for a long time and I use it with joy already, but I want to share my joy with the community.
I want to add examples, tests, how to guides in the readme and so on. I also have to run the tests, which is difficult for me under windows, because the tools don't work so well and I'm lacking time to do it on Linux.
The reason for those pull requests is that I want to get in touch with you first and get feedback on how to change or rename certain things.
This pull request is for the feature that the generator sets the field to the initial value if the deserialized value is missing or null.
Without it all values are written to the fields even if the deserialized value is null or not found:
With it, it checks if the deserialized value is null and if so it assigns the value that was already assigned to it.
What I want to know is the following:
this
can't be used as in..settings = valueFromJson ?? this.settings;
becausethis.settings
doesn't exist in the mixing but in the class that uses the mixin. An extra object is needed for that and like that it's not a single statement anymore which adds the return statement and the curly braces.