Add fromJsonElement method to generated models#1148
Merged
Conversation
This should be more for nested models, and makes it easier for Flutter to build the models from the Maps we'll get back from the method channel.
fuzzybinary
force-pushed
the
jward/from-json-element-generator
branch
from
November 18, 2022 02:09
29d1f2d to
ad2e85f
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1148 +/- ##
===========================================
- Coverage 83.11% 83.01% -0.10%
===========================================
Files 275 275
Lines 9528 9683 +155
Branches 1556 1568 +12
===========================================
+ Hits 7919 8038 +119
- Misses 1160 1188 +28
- Partials 449 457 +8
|
0xnm
reviewed
Nov 18, 2022
Also clean up to use .asJsonObject and catch IllegalStateExceptions during String parse.
fuzzybinary
force-pushed
the
jward/from-json-element-generator
branch
from
November 18, 2022 15:36
664a0b5 to
2060705
Compare
xgouchet
approved these changes
Nov 21, 2022
0xnm
approved these changes
Nov 21, 2022
0xnm
approved these changes
Nov 21, 2022
0xnm
approved these changes
Nov 21, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Add a method to the model generator to change the current
fromJsonmethod to parse the JSON, then pass the result tofromJsonElement. Additionally, change all of the methods that usedfromJsonfor nested objects to instead usefromJsonElementfor efficiency.Motivation
This should be more for nested models, and makes it easier for Flutter to build the models from the Maps we'll get back from the method channel. Otherwise, Flutter will need to convert the object from a map to a JSON string, then ask the model to parse it back out.
Review checklist (to be filled by reviewers)