isar / isar/hive

Clear boxes

Open
#839 2 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Question**
Hi guys, what I want to do is delete all the data from the boxes and start saving data again. I did the next method to reset the boxes, but I get this error: "the box has been closed".
How could I re-open the boxes once they are closed or how to complete clear boxes and memory ?
Thank you very much for your answers : )

**Code sample**

```
Future resetBoxes() async {
// clear
await usersBOX.clear();
await expensesBOX.clear();
// compact
await usersBOX.compact();
await expensesBOX.compact();
// close
await Hive.close();
// re open boxes
await Hive.openBox('USERS-BOX');
await Hive.openBox('EXPENSE-BOX');
}
```

**Version**
- Platform: Android
- Flutter version: 2.5
- 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.