SharedPreferencesPolicyRepository class final
A persistent IPolicyRepository backed by SharedPreferences.
Serializes the policy to JSON using PolicyJsonCodec and stores it under
storageKey. Suitable for applications that need policies to survive app
restarts.
Obtain an instance via the async factory
SharedPreferencesPolicyRepository.create.
- Implemented types
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
-
clear(
) → Future< Result< void, DomainFailure> > -
Removes all stored policy data.
override
-
load(
) → Future< Result< Policy, DomainFailure> > -
Loads the stored Policy.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
save(
Policy policy) → Future< Result< void, DomainFailure> > -
Persists
policyto the underlying storage.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
) → Future< SharedPreferencesPolicyRepository> -
Creates a SharedPreferencesPolicyRepository by obtaining an instance
of
SharedPreferences.
Constants
- storageKey → const String
- The SharedPreferences key under which policies are stored.