From 413ae3594f7142eb8b4b428f60c5c090d12d0799 Mon Sep 17 00:00:00 2001 From: Milo Gilad Date: Thu, 15 Jul 2021 10:03:01 -0400 Subject: [PATCH] Ensure HiveLists are treated as non-nullable in hive_generator (#728) * Replaced ?. operator with . operator Resolves error "The argument type 'HiveList?' can't be assigned to the parameter type 'HiveList'. Closes issue #664. * Ensuring nullable HiveLists are properly generated Co-authored-by: Misir Jafarov --- hive_generator/lib/src/class_builder.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hive_generator/lib/src/class_builder.dart b/hive_generator/lib/src/class_builder.dart index beeeba790..8b9ce0202 100644 --- a/hive_generator/lib/src/class_builder.dart +++ b/hive_generator/lib/src/class_builder.dart @@ -93,7 +93,7 @@ class ClassBuilder extends Builder { String _cast(DartType type, String variable) { var suffix = _suffixFromType(type); if (hiveListChecker.isAssignableFromType(type)) { - return '($variable as HiveList$suffix)?.castHiveList()'; + return '($variable as HiveList$suffix)$suffix.castHiveList()'; } else if (iterableChecker.isAssignableFromType(type) && !isUint8List(type)) { return '($variable as List$suffix)${_castIterable(type)}';