Remove null check when parameter is not nullable in dart

This commit is contained in:
westito 2022-08-01 12:03:43 +02:00
parent b2cb0f6000
commit 4bb36488e1
1 changed files with 3 additions and 1 deletions

View File

@ -228,7 +228,9 @@ class DataClassWriter {
// We include all columns that are not null. If nullToAbsent is false, we
// also include null columns. Since we' generating NNBD code, we can
// include non-nullable columns without an additional null check.
final needsNullCheck = column.nullable;
final needsNullCheck = column.typeConverter != null
? column.typeConverter!.dartTypeIsNullable
: column.nullable;
final needsScope = needsNullCheck || column.typeConverter != null;
if (needsNullCheck) {
_buffer.write('if (!nullToAbsent || ${column.dartGetterName} != null)');