streambox_adapters
A set of ready-to-use storage adapters for the
streambox_core framework.
Provides pluggable implementations of KeyValueStoreInterface for common
Flutter & Dart storage backends.
β¨ Features
- Drop-in storage adapters for
streambox_core - Built-in support for:
- Memory-only store
- SharedPreferences (async)
- SharedPreferences with in-memory caching
- FlutterSecureStorage for encrypted values
- Unified
KeyValueStoreInterfacecontract - Easy integration with custom cache strategies
π¦ Installation
dependencies:
streambox_core: ^latest_version
streambox_adapters: ^latest_version
π Why a Separate Package?
The streambox_adapters package was split from streambox_core to:
- Keep the core library lightweight and focused on abstractions
- Avoid extra dependencies for users who donβt need adapters
- Allow faster independent updates to adapters without releasing a new
version of
streambox_core - Provide a clean modular design, so you only import what you need
ποΈ Available Adapters
MemoryStoreAdapter
- Stores values in memory only
- Perfect for testing, prototyping, ephemeral caches
- Persistence: β (cleared when app restarts)
AsyncSharedPrefsStorageAdapter
- Uses the asynchronous
SharedPreferencesAsyncAPI - Great for general persistent storage with async access
- Persistence: β (shared preferences)
CachedSharedPrefsStorageAdapter
- Backed by
SharedPreferencesWithCache - Reduces disk I/O via in-memory caching
- Persistence: β (cached + disk-backed)
FlutterSecureStorageAdapter
- Backed by
flutter_secure_storage - Encrypted and secure key-value storage
- Ideal for sensitive data (tokens, credentials)
- Persistence: β (secure & encrypted)
π Example Usage
import 'package:streambox_core/streambox_core.dart';
import 'package:streambox_adapters/streambox_adapters.dart';
final repo = ExampleRepoImpl(
dataSource: ExampleDataSource(
api: ExampleApiInterface(dio),
cacheStrategy: CacheThenRefreshStrategy(
cache: BaseKeyValueCache(
store: FlutterSecureStorageAdapter(),
),
),
),
);
If you donβt need persistence:
cacheStrategy: NoOpCacheStrategy(),
π Extensibility
You can implement:
- Custom adapters via
KeyValueStoreInterface - Your own persistent backends (e.g., Hive, Isar, SQLite)
- Specialized storage layers for advanced use cases