SignalsKeyValueStore class abstract

An abstract class defining the persistence adapter contract for PersistedSignal.

Implement this interface to bind PersistedSignal to your storage engine of choice, such as local files, SQLite, SharedPreferences, Hive, or indexedDB.

Example: Custom Shared Preferences Store (Flutter)

import 'package:shared_preferences/shared_preferences.dart';
import 'package:signals/signals.dart';

class SharedPreferencesStore implements SignalsKeyValueStore {
  final SharedPreferences prefs;
  SharedPreferencesStore(this.prefs);

  @override
  Future<String?> getItem(String key) async {
    return prefs.getString(key);
  }

  @override
  Future<void> setItem(String key, String value) async {
    await prefs.setString(key, value);
  }

  @override
  Future<void> removeItem(String key) async {
    await prefs.remove(key);
  }
}

@link https://dartsignals.dev/utilities/persisted

Constructors

SignalsKeyValueStore()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getItem(String key) Future<String?>
Gets an item from the store.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeItem(String key) Future<void>
Removes an item from the store.
setItem(String key, String value) Future<void>
Sets an item in the store.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

defaultStore SignalsKeyValueStore
The default store to be used if no store is provided.
getter/setter pair