A box contains and manages a collection of key-value pairs.
Constructors
- Box()
Properties
- directory → String?
-
The location of the box in the file system. In the browser, this is null.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether the box is empty.
no setter
- isNotEmpty → bool
-
Whether the box is not empty.
no setter
- isOpen → bool
-
Whether this box is currently open.
no setter
-
keys
→ List<
String> -
All the keys in the box.
no setter
- length → int
-
The number of entries in the box.
no setter
- name → String
-
The name of the box.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
E value) → void -
Saves the
value
with an auto-increment key. -
addAll(
Iterable< E> values) → void -
Saves all the
values
with auto-increment keys. -
clear(
{bool notify = true}) → void - Removes all entries from the box.
-
close(
) → void - Closes the box.
-
containsKey(
String key) → bool -
Checks whether the box contains the
key
. -
delete(
String key) → bool -
Deletes the given
key
from the box. -
deleteAll(
Iterable< String> keys) → int -
Deletes all the given
keys
from the box. -
deleteAt(
int index) → void - Deletes the n-th key from the box.
-
deleteFromDisk(
) → void - Removes the file which contains the box and closes the box.
-
deleteRange(
int start, int end) → void - Deletes all the entries in the given range.
-
get(
String key, {E? defaultValue}) → E? -
exist,
null
is returned. -
getAll(
Iterable< String> keys) → List<E?> -
Returns all values associated with the given
keys
ornull
if a key does not exist. -
getAt(
int index) → E - Returns the value associated with the n-th key.
-
getBetween(
{String? startKey, String? endKey}) → List< E> -
Returns all values between
startKey
andendKey
(inclusive). -
getRange(
int start, int end) → List< E> - Returns all values in the given range.
-
keyAt(
int index) → String? - Get the n-th key in the box.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
String key, E value) → void -
Saves the
key
-value
pair. -
putAll(
Map< String, E> entries) → void -
Saves all the key - value pairs in the
entries
map. -
putAt(
int index, E value) → void -
Associates the
value
with the n-th key. An exception is raised if the key does not exist. -
putRange(
int start, int end, Iterable< E> values) → void -
Overwrites the values in the given range with the given
values
. -
read<
T> (T callback()) → T - Start a read transaction on the box.
-
toString(
) → String -
A string representation of this object.
inherited
-
watch(
) → Stream< void> - Returns a broadcast stream of all changes to the box. This should mainly be used to be notified of changes in background isolates.
-
watchKey(
String key) → Stream< E?> -
Watch for changes to the given
key
. -
write<
T> (T callback()) → T - Start a write transaction on the box.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
Object key) → E? -
Returns the value associated with the given
key
. The key can either be a String or an int to get an entry by its index. -
operator []=(
Object key, E value) → void -
Saves the
key
-value
pair. The key can either be a String or an int to save an entry by its index.