Last updated:
0 purchases
shared preferences stateful service cache
shared_preferences-based cache implementation for stateful_service.
Getting started #
See the stateful_service package documentation for more information on how to get started.
Once you have a StatefulService, you can use SharedPreferencesStatefulServiceCache to cache the
service's state using SharedPreferences.
class UserService extends StatefulService<User> {
UserService({required super.initialState})
: super(
cache: SharedPreferencesStatefulServiceCache(
key: 'userServiceState',
encode: (user) => user.name,
decode: (name) => User(name: name),
),
);
...
}
copied to clipboard
Caveats #
Since shared_preferences keeps all its data in memory, it's not recommended to use this cache for
services with large states. In such cases, consider using a different cache implementation.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.