scoped_store 0.2.2 copy "scoped_store: ^0.2.2" to clipboard
scoped_store: ^0.2.2 copied to clipboard

Minimal reactive-store + scoped dependency injection for Flutter. Retain and release stores by reference count, wire them into widgets with one line, rebuild on value change. Five files, zero codegen.

0.2.2 #

Documentation-only release. Rewrote the README to cover the 0.2.x API: removed the StoreRegistry section (gone since 0.2.0), added side-by-side examples for all four widget styles (StoreBuilder, OwnedStoreView, StoreView, StoreStateMixin), documented *ById keyed instances, registerFactory lazy singletons, the AutoReleaseScopedStore mixin, and a testing pattern. No code changes.

0.2.1 #

GetX-style helpers for screens that read or own a store, so screens don't have to call StoreManager.instance directly or nest a StoreBuilder.

Added #

  • StoreView<T> — stateless base. Exposes a store getter via StoreManager.instance.get<T>() (or getById<T> when id is overridden). No lifecycle; assumes a parent owns the retain.
  • OwnedStoreView<T> — stateful base that owns the lifecycle. Override createStore() and build(context, store); the widget retains on initState and releases on dispose. Supports id-keyed instances via the id override.
  • StoreStateMixin<T, W> — mixin for existing State<W> classes that need the same retain/release lifecycle without changing the base class. Override createStore() (and optionally storeId) and access the store via the store getter.

0.2.0 #

Reworked StoreManager to own its instance cache directly, decoupling scoped lifecycle from the underlying get_it container. Adds id-keyed stores so multiple instances of the same type can coexist, and a mixin for auto-releasing retains on dispose.

Breaking #

  • Removed StoreRegistry. Use retainById<T> / releaseById<T> / getById<T> on StoreManager (or the global shorthands) for keyed instances of the same type.
  • StoreManager no longer registers retained instances in the underlying container or unregisters them on release. It now holds its own instance cache, so a get_it factory registration (e.g. @injectable) won't break refcounting by handing out fresh instances on every get<T>().

Added #

  • retainById<T>(id, [factory]), releaseById<T>(id), getById<T>(id), tryGetById<T>(id), getRefCountById<T>(id) for managing multiple instances of the same type, keyed by a runtime id.
  • tryGet<T>() global shorthand — returns null instead of throwing.
  • registerFactory<T> global shorthand for lazy factory registration. First lookup auto-retains; matching release disposes when refcount hits zero.
  • AutoReleaseScopedStore mixin (on Disposable) — records retainStore<T> / retainStoreById<T> calls and releases them in LIFO order from onDispose.
  • Debug-mode warnings when more than one StoreManager is constructed in a single isolate (hot restart, second isolate, or singleton bypass). Exposes instanceId and totalInstancesCreated.

0.1.0 #

Initial release. Three files — reference-counted store lifecycle, zero opinions about how your state updates.

  • StoreManager — singleton DI registry with retain<T> / release<T> / get<T> / tryGet<T> / getWithKey / scoped child registries.
  • StoreBuilder<T> — widget that retains a store for its subtree and releases it on dispose. Pair with any reactive builder.
  • StoreRegistry — keyed registry for multiple instances of the same type.

No reactive primitive is included. Bring your own: ChangeNotifier, ValueNotifier, Riverpod, Bloc, signals — anything a store can hold and a Flutter widget can listen to.

1
likes
130
points
15
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Minimal reactive-store + scoped dependency injection for Flutter. Retain and release stores by reference count, wire them into widgets with one line, rebuild on value change. Five files, zero codegen.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter, get_it

More

Packages that depend on scoped_store