From 4bb36488e19e6ad34338fb4fcaafbbbf89c13509 Mon Sep 17 00:00:00 2001 From: westito Date: Mon, 1 Aug 2022 12:03:43 +0200 Subject: [PATCH] Remove null check when parameter is not nullable in dart --- drift_dev/lib/src/writer/tables/data_class_writer.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drift_dev/lib/src/writer/tables/data_class_writer.dart b/drift_dev/lib/src/writer/tables/data_class_writer.dart index 06108fa1..15d858bc 100644 --- a/drift_dev/lib/src/writer/tables/data_class_writer.dart +++ b/drift_dev/lib/src/writer/tables/data_class_writer.dart @@ -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)');