di-and-architecture

Enforce dependency injection and three-tier architecture in Flutter applications.

1|1|Updated Jun 21, 2025
One-click install
npx skills add https://github.com/AdhamHashim/Flutter_Base --skill di-and-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: di-and-architecture
Source: https://github.com/AdhamHashim/Flutter_Base/tree/main/.claude/skills/di-and-architecture
Command: npx skills add https://github.com/AdhamHashim/Flutter_Base --skill di-and-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enforces consistent Dependency Injection (DI) practices and a clear layering architecture within the Flutter_Base project, preventing manual service instantiation and ensuring maintainability.

Core Features & Use Cases

  • Standardized DI: Ensures all services (Cubits, UseCases, Repositories) are injected using the injector<T>() function, not manually constructed.
  • Layered Architecture Enforcement: Maintains strict separation between Presentation, Domain, and Data layers, defining responsibilities for each.
  • Endpoint Management: Centralizes API endpoints in ApiConstants to avoid hardcoding.
  • Use Case: When adding a new feature, this Skill guides developers to correctly register new Cubits and UseCases with the DI container and structure their code according to the established layers.

Quick Start

Run the build_runner build command to generate necessary injectable files after adding a new Cubit or UseCase.

Frequently Asked Questions about di-and-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce dependency injection in a Flutter application?

To enforce dependency injection in Flutter, use the `injector<T>()` function for all services like Cubits, UseCases, and Repositories instead of manually constructing them, ensuring maintainability and consistent service location across your project.

What is the correct way to structure a Flutter feature with Cubit and UseCase?

Structuring a Flutter feature requires maintaining a three-tier architecture: Presentation, Domain, and Data layers. You must register new Cubits and UseCases with the DI container and separate business logic from data access.

Do I need to run build_runner when adding a new Cubit in Flutter?

Yes, you must run the `build_runner` build command to generate necessary injectable files after adding a new Cubit or UseCase, allowing the dependency injection container to automatically register the new services.

How do I centralize API endpoints in a Flutter project?

Centralize API endpoints by defining them within an `ApiConstants` class rather than hardcoding URLs. This architectural practice avoids scattered strings and ensures maintainable network configuration across the data layer.

Why does my Flutter dependency injection fail to locate a newly added repository?

Dependency injection fails to locate a new repository when injectable files are outdated. You must execute the `build_runner` build command to regenerate the DI configuration after adding or modifying any injected service.