Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
looks like you're missing a dependency override in json_serializable |
|
@ChreSyr – I landed some fixes – take a look! |
| ## 4.8.2-wip | ||
|
|
||
| - Require Dart 3.0 | ||
| - Added `JsonSerializable(createJsonKeys: true)`. |
There was a problem hiding this comment.
This should be 4.9.0 since we're adding new features!
There was a problem hiding this comment.
Ditto with json_serial. I'll do it. Just FYI for future.
| static const jsonKeys = ModelJsonKeys; | ||
| } | ||
|
|
||
| typedef ModelJsonKeys = _$ModelJsonKeys; |
There was a problem hiding this comment.
Smart, i like the idea
There was a problem hiding this comment.
@ChreSyr would be really nice to have this auto generated inside json_keys_example.g.dart above the generated ModelJsonKeys class
|
Thanks @kevmoo for your help and work ! It was my first experience in open-source contribution, I will definitely continue. |
|
|
||
| Map<String, dynamic> _$ModelToJson(Model instance) => <String, dynamic>{ | ||
| 'first-name': instance.firstName, | ||
| 'LAST_NAME': instance.lastName, |
There was a problem hiding this comment.
should these keys use the same above constants?
|
|
||
| Model _$ModelFromJson(Map<String, dynamic> json) => Model( | ||
| firstName: json['first-name'] as String, | ||
| lastName: json['LAST_NAME'] as String, |
There was a problem hiding this comment.
should these keys use constants from the _$ModelJsonKeys?
There was a problem hiding this comment.
Maybe? I thought about it. Just makes things a bit more complex to implement.
There was a problem hiding this comment.
Maybe? I thought about it. Just makes things a bit more complex to implement.
@kevmoo My main driver is to see usages/references of these field names constants. Without it, these two places fall off the grid.
|
|
||
| abstract final class _$ModelJsonKeys { | ||
| static const String firstName = 'first-name'; | ||
| static const String lastName = 'LAST_NAME'; |
There was a problem hiding this comment.
I'm curious why not using enum here? Like enum _$ModelJsonKeys { firstName('first-name'), ...

See #1400