Retrieve box elements and obtain key when using ListView.builder
- 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.