diff --git a/lib/db/hive/db.dart b/lib/db/hive/db.dart index 25efcdb3e..9d3f73abd 100644 --- a/lib/db/hive/db.dart +++ b/lib/db/hive/db.dart @@ -274,8 +274,15 @@ class DB { {required dynamic key, required String boxName}) async => await mutex.protect(() async => await Hive.box(boxName).delete(key)); - Future deleteAll({required String boxName}) async => - await mutex.protect(() async => await Hive.box(boxName).clear()); + Future deleteAll({required String boxName}) async { + await mutex.protect(() async { + Box box = Hive.box(boxName); + if (!box.isOpen) { + box = await Hive.openBox(boxName); + } + await box.clear(); + }); + } Future deleteBoxFromDisk({required String boxName}) async => await mutex.protect(() async => await Hive.deleteBoxFromDisk(boxName));