From fecc4966d922847115578999a7c44b7f9d4d5774 Mon Sep 17 00:00:00 2001 From: Milo Gilad Date: Wed, 14 Jul 2021 21:17:24 -0400 Subject: [PATCH 1/2] Replaced ?. operator with . operator Resolves error "The argument type 'HiveList?' can't be assigned to the parameter type 'HiveList'. Closes issue #664. --- 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..7088c303e 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).castHiveList()'; } else if (iterableChecker.isAssignableFromType(type) && !isUint8List(type)) { return '($variable as List$suffix)${_castIterable(type)}'; From 778269b9134d8810802ba38e32d4370ec905fd84 Mon Sep 17 00:00:00 2001 From: Milo Gilad Date: Thu, 15 Jul 2021 09:41:40 -0400 Subject: [PATCH 2/2] 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 7088c303e..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)}';