Skip to content

Commit

Permalink
#130: don't include disallow null if it's not true
Browse files Browse the repository at this point in the history
  • Loading branch information
jorre127 committed Sep 11, 2023
1 parent 102ccbd commit 4cdc535
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/lib/model/user/project/project.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/writer/object_model_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ class ObjectModelWriter {
sb.write(" @JsonKey(name: '${key.serializedName}'");
if (key.isRequired) {
if (key.hasDefaultValue) {
sb.write(', required: false, disallowNullValue: ${key.disallowNull}');
sb.write(', required: false');
if (key.disallowNull) {
sb.write(', disallowNullValue: ${key.disallowNull}');
}
} else {
sb.write(', required: true');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ part 'person.g.dart';
@JsonSerializable(explicitToJson: true)
class Person {
///A good description
@JsonKey(name: 'firstName', required: false, disallowNullValue: false)
@JsonKey(name: 'firstName', required: false)
final String firstName;

const Person({
Expand Down

0 comments on commit 4cdc535

Please sign in to comment.