streambox_adapters 1.4.1 copy "streambox_adapters: ^1.4.1" to clipboard
streambox_adapters: ^1.4.1 copied to clipboard

Storage adapters for streambox_core: memory, SharedPrefs, secure storage.

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.

pub package style: very good analysis Verified Publisher


✨ 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 KeyValueStoreInterface contract
  • 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 SharedPreferencesAsync API
  • 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
0
likes
155
points
45
downloads

Publisher

verified publisherkalaganov.dev

Weekly Downloads

Storage adapters for streambox_core: memory, SharedPrefs, secure storage.

Repository (GitHub)
View/report issues

Topics

#repository #caching #reactive #strategy #core

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_secure_storage, meta, shared_preferences, streambox_core

More

Packages that depend on streambox_adapters