Fix not null when using JsonTypeConverter (#1820)

* Fix not null when using JsonTypeConverter

* Run dart format on writer

Co-authored-by: Alexander Wilde <alexander.wilde87@gmail.com>
Co-authored-by: Simon Binder <oss@simonbinder.eu>
This commit is contained in:
North101 2022-04-25 15:21:01 +01:00 committed by GitHub
parent d23028a5bb
commit 5bf9b2a3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -144,8 +144,10 @@ class DataClassWriter {
if (typeConverter != null && typeConverter.alsoAppliesToJsonConversion) {
final type = column.innerColumnType(scope.generationOptions);
final fromConverter = "serializer.fromJson<$type>(json['$jsonKey'])";
final notNull =
!column.nullable && scope.generationOptions.nnbd ? '!' : '';
deserialized =
'${typeConverter.tableAndField}.fromJson($fromConverter)';
'${typeConverter.tableAndField}.fromJson($fromConverter)$notNull';
} else {
final type = column.dartTypeCode(scope.generationOptions);