-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add JsonSerializable(createJsonMeta)
- Loading branch information
1 parent
dee0e5a
commit 1b692aa
Showing
12 changed files
with
114 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'json_meta_example.g.dart'; | ||
|
||
@JsonSerializable(createJsonMeta: true, fieldRename: FieldRename.kebab) | ||
class Model { | ||
Model({ | ||
required this.firstName, | ||
required this.lastName, | ||
this.ignoredName, | ||
}); | ||
|
||
factory Model.fromJson(Map<String, Object?> json) => _$ModelFromJson(json); | ||
|
||
final String firstName; | ||
|
||
@JsonKey(name: 'LAST_NAME') | ||
final String lastName; | ||
|
||
@JsonKey(ignore: true) | ||
final String? ignoredName; | ||
|
||
String get fullName => '$firstName $lastName'; | ||
|
||
Map<String, Object?> toJson() => _$ModelToJson(this); | ||
} | ||
|
||
const modelMeta = _$ModelJsonMeta; |
24 changes: 24 additions & 0 deletions
24
json_serializable/test/integration/json_meta_example.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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