Box<E> class

Boxes contain all of your data. In the browser, each box has its own IndexedDB database. On all other platforms, each Box is stored in a separate file in the Hive home directory.

Write operations are asynchronous but the new values are immediately available. The returned Future finishes when the change is written to the backend. If this operation fails, the changes are being reverted.

Read operations for normal boxes are synchronous (the entries are in memory). Lazy boxes have asynchronous read operations.

Implemented types




hashCode → int
The hash code for this object. [...]
read-only, inherited
isEmpty → bool
Returns true if there are no entries in this box.
read-only, inherited
isNotEmpty → bool
Returns true if there is at least one entries in this box.
read-only, inherited
isOpen → bool
Whether this box is currently open. [...]
read-only, inherited
keys → Iterable
All the keys in the box. [...]
read-only, inherited
lazy → bool
Whether this box is lazy or not. [...]
read-only, inherited
length → int
The number of entries in the box.
read-only, inherited
name → String
The name of the box. Names are always lowercase.
read-only, inherited
path → String
The location of the box in the file system. In the browser, this is null.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
values → Iterable<E>
All the values in the box. [...]


add(E value) → Future<int>
Saves the value with an auto-increment key.
addAll(Iterable<E> values) → Future<Iterable<int>>
Saves all the values with auto-increment keys.
clear() → Future<int>
Removes all entries from the box.
close() → Future<void>
Closes the box. [...]
compact() → Future<void>
Induces compaction manually. This is rarely needed. You should consider providing a custom compaction strategy instead.
containsKey(dynamic key) → bool
Checks whether the box contains the key.
delete(dynamic key) → Future<void>
Deletes the given key from the box. [...]
deleteAll(Iterable keys) → Future<void>
Deletes all the given keys from the box. [...]
deleteAt(int index) → Future<void>
Deletes the n-th key from the box. [...]
deleteFromDisk() → Future<void>
Removes the file which contains the box and closes the box. [...]
get(dynamic key, {E defaultValue}) → E
Returns the value associated with the given key. If the key does not exist, null is returned. [...]
getAt(int index) → E
Returns the value associated with the n-th key.
keyAt(int index) → dynamic
Get the n-th key in the box.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
put(dynamic key, E value) → Future<void>
Saves the key - value pair.
putAll(Map<dynamic, E> entries) → Future<void>
Saves all the key - value pairs in the entries map.
putAt(int index, E value) → Future<void>
Associates the value with the n-th key. An exception is raised if the key does not exist.
toMap() → Map<dynamic, E>
Returns a map which contains all key - value pairs of the box.
toString() → String
Returns a string representation of this object.
valuesBetween({dynamic startKey, dynamic endKey}) → Iterable<E>
Returns an iterable which contains all values starting with the value associated with startKey (inclusive) to the value associated with endKey (inclusive). [...]
watch({dynamic key}) → Stream<BoxEvent>
Returns a broadcast stream of change events. [...]


operator ==(Object other) → bool
The equality operator. [...]