Skip to content

Commit

Permalink
Ensure HiveLists are treated as non-nullable in hive_generator (#728)
Browse files Browse the repository at this point in the history
* Replaced ?. operator with . operator

Resolves error "The argument type 'HiveList<T>?' can't be assigned to the parameter type 'HiveList<T>'.

Closes issue #664.

* Ensuring nullable HiveLists are properly generated

Co-authored-by: Misir Jafarov <[email protected]>
  • Loading branch information
Milo Gilad and themisir authored Jul 15, 2021
1 parent 8873f75 commit 413ae35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hive_generator/lib/src/class_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)}';
Expand Down

0 comments on commit 413ae35

Please sign in to comment.