diff --git a/hive/lib/src/hive.dart b/hive/lib/src/hive.dart index 755fc41f9..8946ea1e0 100644 --- a/hive/lib/src/hive.dart +++ b/hive/lib/src/hive.dart @@ -35,7 +35,7 @@ abstract class HiveInterface implements TypeRegistry { bool crashRecovery = true, String? path, @Deprecated('Use [backend] with a [StorageBackendMemory] instead') - Uint8List? bytes, + Uint8List? bytes, StorageBackend? backend, String? collection, @Deprecated('Use encryptionCipher instead') List? encryptionKey, @@ -86,6 +86,8 @@ abstract class HiveInterface implements TypeRegistry { /// Checks if a box exists Future boxExists(String name, {String? path}); + Iterable listBoxes(); + /// Clears all registered adapters. /// /// To register an adapter use [registerAdapter]. diff --git a/hive/lib/src/hive_impl.dart b/hive/lib/src/hive_impl.dart index e11875ef0..51ca419cf 100644 --- a/hive/lib/src/hive_impl.dart +++ b/hive/lib/src/hive_impl.dart @@ -30,7 +30,7 @@ class HiveImpl extends TypeRegistryImpl implements HiveInterface { bool useLocks = true; - bool wasInitialized=false; + bool wasInitialized = false; /// Not part of public API HiveImpl() { @@ -58,7 +58,7 @@ class HiveImpl extends TypeRegistryImpl implements HiveInterface { homePath = path; _managerOverride = BackendManager.select(backendPreference); this.useLocks = useLocks; - wasInitialized=true; + wasInitialized = true; } Future> _openBox( @@ -138,7 +138,7 @@ class HiveImpl extends TypeRegistryImpl implements HiveInterface { bool crashRecovery = true, String? path, @Deprecated('Use [backend] with a [StorageBackendMemory] instead') - Uint8List? bytes, + Uint8List? bytes, StorageBackend? backend, String? collection, @Deprecated('Use encryptionCipher instead') List? encryptionKey, @@ -268,6 +268,14 @@ class HiveImpl extends TypeRegistryImpl implements HiveInterface { var lowerCaseName = name.toLowerCase(); return await manager.boxExists(lowerCaseName, path ?? homePath, collection); } + + @override + Iterable listBoxes() { + var boxesNames = _boxes.values.toList().map((box) { + return box.name; + }); + return boxesNames; + } } /// tiny helper for map key management...