← ClaudeAtlas

create-storelisted

Build a MobX store — @readonly observables, @action mutations, DioService access, error handling, and the @injectable vs @singleton scope decision. Use when adding or modifying any *_store.dart, or when deciding whether logic belongs in a store or a page state.
NarekManukyan/flutter-mobx-kit · ★ 0 · AI & Automation · score 70
Install: claude install-skill NarekManukyan/flutter-mobx-kit
# Create a MobX store Governed by [ADR-0002](../../../docs/adr/0002-state-vs-store-separation.md) (state vs store), [ADR-0006](../../../docs/adr/0006-feature-owned-singletons.md) (feature-owned), [ADR-0007](../../../docs/adr/0007-di-scopes-and-constructor-injection.md) (DI scopes). ## Store or state? | Question | Store (`*_store.dart`) | State (`*_state.dart`) | |---|---|---| | Needs API access? | yes — injects `DioService` | no — calls stores / use cases | | Outlives one screen? | often | never | | Location | `lib/features/{feature}/mobx/` | `lib/features/{feature}/view/` | If it does not touch the network and dies with the screen, it is a state, not a store. ## Location **Always** under the owning feature's `mobx/`, regardless of scope. A `@singleton AuthStore` lives at `lib/features/auth/mobx/auth_store.dart` — not in `lib/shared/`, not in `lib/core/`. ## Scope - `@injectable` — a new instance per resolution. Feature stores whose data does not need to survive navigation. - `@singleton` — one instance for the app. Session, connectivity, notifications, anything two features read. - `@lazySingleton` — app-wide but expensive; constructed on first resolution (e.g. `DioService`). Choose `@injectable` unless a second consumer genuinely needs the same instance. A singleton is a decision to keep state alive for the whole process — it is not free. ## Shape ```dart part 'home_store.g.dart'; @singleton class HomeStore = _HomeStoreBase with _$HomeStore; abstract class _Hom