PersistState<T> class

A lightweight state management solution with automatic persistence

Constructors

PersistState({required String key, required T defaultValue, StorageAdapter? storage, bool autoPersist = true, Duration? debounceTime})
Creates a new PersistState instance

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<T>
Stream of value changes
no setter
value → T
Current value of the state
no setter

Methods

delete() Future<void>
Delete the persisted value
dispose() → void
Dispose of resources
hasPersistedValue() Future<bool>
Check if a value is persisted
initialize() Future<void>
Initialize the state by loading from storage
load() Future<void>
Load the value from storage
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
persist() Future<void>
Manually persist the current value to storage
reset() Future<void>
Reset to default value
set(T newValue, {bool? persist}) Future<void>
Update the state value
toString() String
A string representation of this object.
inherited
update(T updater(T currentValue), {bool? persist}) Future<void>
Update the state value using a function

Operators

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