IndexedDbKeyValueStore class final

A KeyValueStore in an IndexedDB database of the page's origin (web).

The database (version 1) has one object store, kv, of string values under string keys. Each update is one readwrite transaction, so it is atomic across every tab of the origin. After each committed write that changed the value the store announces the key (never the value) on a BroadcastChannel named databaseName; changes emits the keys other stores and tabs announce. An update whose transform returns the value it was given writes nothing and announces nothing.

When the browser closes the connection (site data cleared, a version change, a storage error) the next call opens a new one. Where BroadcastChannel is missing the store works without announcing.

Every script of the origin can read the database, including the installation's refresh token.

Implemented types

Constructors

IndexedDbKeyValueStore({String databaseName = 'firebase_dart_kv'})
A store in the IndexedDB database databaseName. Nothing is opened until the first call.

Properties

changes → Stream<String>
Keys changed by another writer where the storage can tell: IndexedDB emits; memory and file stores never emit. A hint to read again; it carries no value.
no setteroverride
databaseName → String
The name of the IndexedDB database and of the BroadcastChannel that announces changes.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → Future<void>
Releases the store. Later calls fail.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(String key) → Future<String?>
The value stored under key, or null when there is none.
override
remove(String key) → Future<void>
Removes key; nothing happens when it is absent.
override
toString() → String
A string representation of this object.
inherited
update(String key, String? transform(String? current)) → Future<String?>
Reads key, calls transform synchronously, writes its result (null removes), returns it.
override
write(String key, String value) → Future<void>
Stores value under key, all or nothing.
override

Operators

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