1---2name: li-lance-android-seraphim-framework-flutter-dependency-injec3description: Dependency Injection4---56# Dependency Injection78## **Priority: P1 (HIGH)**910Automated class dependency management using `get_it` and `injectable`.1112## Structure1314```text15core/injection/16├── injection.dart # Initialization & setup17└── modules/ # Third-party dependency modules (Dio, Storage)18```1920## Implementation Workflow21221. **Annotate classes** — Use `@injectable` annotations; avoid manual registry calls.232. **Choose scope** — Default to `@LazySingleton` for repositories, services, and data sources (init24 on demand).253. **Register BLoCs as factories** — Use `@injectable` (Factory) for BLoCs to ensure state resets26 per instance. Never use `@Singleton()` for BLoCs.274. **Inject abstractions** — Always register implementations as abstract interfaces (28 `as: IService`).295. **Register third-party deps** — Use `@module` for external instances (Dio, Hive,30 SharedPreferences).316. **Prefer constructor injection** — Use mandatory constructor parameters; `injectable` resolves32 them automatically.3334### Registration & Test Mock Examples3536See [implementation examples](references/implementation.md) for module registration and test mock37swap patterns.3839## Reference & Examples4041For module configuration and initialization templates:42See [references/REFERENCE.md](references/REFERENCE.md).4344## Anti-Patterns4546- ❌ `getIt<OrderRepository>()` inside widget `build()` — inject via constructor, not GetIt calls in47 UI48- ❌ `@Singleton()` on a BLoC — BLoCs must use `@injectable` (Factory) so state resets per instance49- ❌ Injecting the concrete class: `OrderRepositoryImpl repo` — always inject the abstract interface50- ❌ `getIt.registerLazySingleton<X>(() => X())` in production code — use `@injectable` annotations;51 manual registration is only for tests5253## Related Topics5455layer-based-clean-architecture | testing5657---58> Source: [li-lance/android-seraphim-framework](https://github.com/li-lance/android-seraphim-framework) — distributed by [TomeVault](https://tomevault.io).59<!-- tomevault:4.0:skill_md:2026-06-16 -->
Run npx skillmds@latest add tomevault-io/li-lance-android-seraphim-framework-flutter-dependency-injec in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Dependency Injection It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.