Open Johannes5000 opened 12 months ago
Since Version 6.7.0 Records are supported.
If I am right, there is currently no possibility to set a default value for a field inside the record.
For example:
@JsonSerializable() class MyClass { final ({ double numberWithDefault, String someOtherText, }) myRecord; @JsonKey(defaultValue: 0.0) final double anotherNumberWithDefault; MyClass({ required this.myRecord, required this.anotherNumberWithDefault, }); factory MyClass.fromJson(Map<String, dynamic> json) => _$MyClassFromJson(json); Map<String, dynamic> toJson() => _$MyClassToJson(this); }
It would be nice to be able to set numberWithDefault to a default value, if the json value is null (just like anotherNumberWithDefault).
numberWithDefault
anotherNumberWithDefault
Since Version 6.7.0 Records are supported.
If I am right, there is currently no possibility to set a default value for a field inside the record.
For example:
It would be nice to be able to set
numberWithDefault
to a default value, if the json value is null (just likeanotherNumberWithDefault
).