isar / isar/hive

Retrieve box elements and obtain key when using ListView.builder

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

Description

Using Hive, I can `Hive.openBox('boxName')` to then pass into a `ListView.builder` and cast the entry to a Model to get the required information for my view like this:

```
ListView.builder(
itemCount: list?.length,
itemBuilder: (context, index) {
final location = list.getAt(index) as Location; //casting to a Model

//Widget code here to use location.ModelProperty, etc.
},
)
```

This works great, but I really need to be able to get the box's entry key record. All of my records are being saved with a key like `await box.put(nowSinceEpoch.toString(), data)`. How would I refactor this to still be able to pass in the box itself, and not have to do additional mapping or manipulation of the data being passed into the `ListView.builder`?

**Version**
- Platform: iOS, Android
- Flutter version: 1.23.0-18.1.pre • channel beta
- Hive version: ^1.4.4+1

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.