BoxConfig class

Immutable configuration for creating or opening a Hive box.

This class encapsulates all options required to configure a box, including its name, type, encryption, crash recovery, storage path, collection, and logging.

Use the provided named constructors for convenience, or use copyWith to create modified copies of an existing config.

Example:

final config = BoxConfig.lazy(
  'myBox',
  encryptionCipher: myCipher,
  crashRecovery: true,
  path: '/custom/path',
  collection: 'users',
  logger: myLogger,
);
Available extensions

Constructors

BoxConfig(String name, {BoxType type = BoxType.regular, HiveCipher? encryptionCipher, bool crashRecovery = true, String? path, String? collection, LogHandler? logger})
Creates a new BoxConfig with the given parameters.
const
BoxConfig.isolated(String name, {HiveCipher? encryptionCipher, bool crashRecovery = true, String? path, String? collection, LogHandler? logger})
Creates a BoxConfig for an isolated (background isolate) box.
factory
BoxConfig.isolatedLazy(String name, {HiveCipher? encryptionCipher, bool crashRecovery = true, String? path, String? collection, LogHandler? logger})
Creates a BoxConfig for an isolated lazy box.
factory
BoxConfig.lazy(String name, {HiveCipher? encryptionCipher, bool crashRecovery = true, String? path, String? collection, LogHandler? logger})
Creates a BoxConfig for a lazy box.
factory
BoxConfig.regular(String name, {HiveCipher? encryptionCipher, bool crashRecovery = true, String? path, String? collection, LogHandler? logger})
Creates a BoxConfig for a regular (non-lazy, non-isolated) box.
factory

Properties

collection String?
Optional logical collection name for namespacing.
finalinherited
crashRecovery bool
Whether crash recovery is enabled for this box.
finalinherited
encryptionCipher → HiveCipher?
Optional cipher for transparent encryption/decryption.
finalinherited
hashCode int
The hash code for this object.
no setter
logger → LogHandler?
Optional logger for diagnostics and error reporting.
final
name String
The unique name of the box.
finalinherited
path String?
Optional custom file system path for box storage.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type BoxType
The type of box to create (regular, lazy, isolated, isolatedLazy).
finalinherited

Methods

box<K, T>() Box<K, T>

Available on BoxConfig, provided by the CreateBoxFromConfigExtensions extension

Creates a Box from this BoxConfig.
copyWith({String? name, BoxType? type, HiveCipher? encryptionCipher, bool? crashRecovery, String? path, String? collection, LogHandler? logger}) BoxConfig
Returns a copy of this config with the given fields replaced.
createBox<K, T>() BoxInterface<K, T>

Available on BoxConfig, provided by the CreateHivezBoxFromConfig extension

Creates a BoxInterface of the appropriate type for the given key/value types.
indexedBox({required String searchableText(T), Analyzer analyzer = Analyzer.prefix, TextAnalyzer<T>? overrideAnalyzer, bool matchAllTokens = true, int tokenCacheCapacity = 512, bool verifyMatches = false, int keyComparator(K a, K b)?}) IndexedBox<K, T>

Available on BoxConfig, provided by the CreateIndexedBoxFromConfig extension

Creates an IndexedBox using this BoxConfig.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.

Operators

operator ==(Object other) bool
The equality operator.