UStore class
One key/value store. Obtain with UStorage.instance, UStorage.secure or UStorage.open.
Properties
-
changes
→ Stream<
UStorageChange> -
Every change to this store, including expiries.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
no setter
- isNotEmpty → bool
-
no setter
- isSecure → bool
-
no setter
-
keys
→ Iterable<
String> -
no setter
- length → int
-
no setter
- name → String
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → Future< void> -
Removes every entry except
u's internal "__u." keys. -
expire(
String key, Duration? ttl) → Future< void> - Sets or clears the ttl of an existing entry without rewriting its value.
-
flush(
) → Future< void> - Writes pending changes now instead of at the end of the event-loop turn. Completes once everything set so far is on disk; costs nothing when there is nothing to write.
-
get<
T> (String key) → T? -
The value of
keyasT, or null when missing, expired or of another type. Numbers convert between int and double; JSON lists read asList<String>when asked. -
getEnum<
T extends Enum> (String key, List< T> values) → T? -
Enums are stored by name:
set("mode", ThemeMode.dark)→getEnum("mode", ThemeMode.values). -
getObject<
T> (String key, T fromJson(Map< String, dynamic> json)) → T? -
Reads an object saved with
set(key, object)(anything withtoJson()). -
getObjects<
T> (String key, T fromJson(Map< String, dynamic> json)) → List<T> ? -
Reads a list of objects saved with
set(key, listOfObjects). -
getOr<
T> (String key, T fallback) → T -
has(
String key) → bool -
increment(
String key, {int by = 1}) → int -
Adds
byto the int underkey(missing counts as 0) and returns the new value. -
listenable<
T> (String key) → ValueListenable< T?> -
A ValueListenable for
key, ready forValueListenableBuilder. Shared per key. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String key) → Future< void> -
removeAll(
Iterable< String> keys) → Future<void> -
removeWhere(
bool test(String key, Object value)) → Future< void> -
Removes every entry for which
testreturns true. -
set(
String key, Object? value, {Duration? ttl}) → Future< void> -
Stores
valueunderkey(null removes it). Withttlthe entry disappears once it elapses. Takes effect immediately for readers; the future completes once it is on disk. -
setAll(
Map< String, Object?> entries, {Duration? ttl}) → Future<void> - Stores several entries with one disk write.
-
toMap(
) → Map< String, Object> - A snapshot of every live entry.
-
toString(
) → String -
A string representation of this object.
override
-
ttlOf(
String key) → Duration? -
Time left before
keyexpires; null when it has no ttl or does not exist. -
update<
T> (String key, T? transform(T? current)) → Future< void> -
Replaces the value of
keywithupdate(current); returning null removes it. -
watch<
T> (String key, {bool emitCurrent = true}) → Stream< T?> -
The value of
keynow (whenemitCurrent) and after every change.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited