Chest<T> class
A container for a value that's persisted beyond the app's lifetime.
This is how Chests are typically used:
final counter = Chest('counter', ifNew: () => 0);
await counter.open();
print('This program ran ${counter.value} times.');
counter.value++;
await counter.close();
You don't need to close Chests if you're not absolutely sure you don't need them later on: Even if your program exists while a Chest is opened or its value is being changed, a valid state of the chest is recovered.
Properties
- exists → bool
-
Whether the value that this reference points to exists.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- ifNew → T Function()
-
final
- isOpened → bool
-
no setter
- name → String
-
final
- numberOfChildren → int
-
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T
-
The value this reference points to.
getter/setter pairoverride
- valueOrNull → T?
-
no setterinherited
Methods
-
child<
R> (Object? key, {bool createImplicitly = false}) → Reference< R> -
override
-
close(
) → Future< void> -
compact(
) → Future< void> -
flush(
) → Future< void> -
mock(
[T? value]) → void -
mutate(
void mutater(T value)) → void -
Updates the value by calling the mutating function and then saving the
value.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
) → Future< void> -
remove(
) → Future< void> -
override
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
T updater(T value)) → void -
Updates the value reference with the given function.
inherited
-
valueOr(
T orElse()) → T -
inherited
-
watch(
) → Stream< void> -
A Stream that fires evertime the value that this reference points to
changes.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited