isar / isar/hive

hive generator problem with "late" HiveList

Open
#662 2 comments 0 reactions 0 assignees View on GitHub
problem
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Steps to Reproduce**

1. create a simple model like in https://docs.hivedb.dev/#/README
2. add "late" so that the line is `late HiveList friends;`
3. run the code generator `flutter packages pub run build_runner build`

the code generated would not compile. It has this line
``` return Person()..friends = (fields[0] as HiveList)?.castHiveList();```
which gives this error `A value of type 'HiveList?' can't be assigned to a variable of type 'HiveList'.`

**Code sample**
```
import 'package:hive/hive.dart';

part 'models.g.dart';

@HiveType(typeId: 0)
class Person extends HiveObject {
@HiveField(0)
late HiveList friends;
}```

**Version**
- Platform: iOS, Android, Mac, Windows, Linux, Web
- Flutter version: [2.0.6]
- Hive version: [2.0.4]

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.