rx_shared_preferences
4.0.0, released 2 years ago by hoc081098.dev
Reactive stream wrapper around SharedPreferences for key-value storage.
WASM-ready
What it does
Wraps SharedPreferences with RxDart streams, allowing developers to observe changes to keys reactively. It supports standard data types, objects with decoders, and provides methods to read, write, update, and listen to streams of stored values.
AI-written summary of version 4.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to reactively listen to changes in SharedPreferences using RxDart streams
- You need a lightweight key-value storage solution with stream observation capabilities
Skip it when
- You require complex relational queries or large-scale offline databases
- You are not using RxDart or reactive programming paradigms
Strengths
- Provides clean stream-based observation of SharedPreferences keys
- Requires very little code to integrate
- Supports custom objects via decoders and encoders
Weaknesses
- Returns single-subscription streams that must be handled accordingly
- Dependent on SharedPreferences performance characteristics
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Wrap your SharedPreferences instance in RxSharedPreferences before usage.
final rxPrefs = RxSharedPreferences(await SharedPreferences.getInstance());
rxPrefs.getStringListStream('KEY_LIST').listen(print);
await rxPrefs.setStringList('KEY_LIST', ['Cool']);Alternatives
Packages that do the same job and could replace rx_shared_preferences.
Works with
Packages commonly used together with rx_shared_preferences: ones it builds on, ones built on it, and its own family.