configure-di

Configure GetIt dependency injection in Flutter projects with registration rules.

Updated Apr 1, 2026
One-click install
npx skills add https://github.com/andrelucassvt/CleanMacForDevsWeb --skill configure-di
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: configure-di
Source: https://github.com/andrelucassvt/CleanMacForDevsWeb/tree/main/.agents/skills/configure-di
Command: npx skills add https://github.com/andrelucassvt/CleanMacForDevsWeb --skill configure-di

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Configures dependency injection (GetIt) for Flutter projects following the project architecture. Use whenever adding or modifying registrations in lib/config/inject/**. Covers registerFactory vs registerLazySingleton, registration order, multi-flavor setup, and common mistakes. Activate even when the user says 'register this class in the injector', 'how do I inject this dependency', 'GetIt is throwing an error', 'add this to AppInjector', 'should this be a singleton or factory?', 'I created a new service, where do I register it?', or 'dependency not found' without explicitly mentioning GetIt or registerLazySingleton.

Core Features & Use Cases

  • Provides a standardized pattern for registering services, data sources, repos, and cubits.
  • Enforces registerFactory for cubits and registerLazySingleton for services, repositories, and data sources.
  • Supports multi-flavor setups and safe dependency resolution via AppInjector.

Quick Start

Configure AppInjector by calling setupDependencies with a flavor, then resolve cubits via AppInjector.

Frequently Asked Questions about configure-di

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

FAQPage Schema
How do I configure Flutter dependency injection with GetIt across multiple flavors?

Configure Flutter dependency injection by calling setupDependencies with a specific flavor to safely resolve services, data sources, and repositories. This ensures proper registration order and handles multi-flavor setups using an AppInjector template.

When should I use registerFactory vs registerLazySingleton for cubits and services in GetIt?

Use registerFactory for cubits to ensure fresh instances and proper disposal, while use registerLazySingleton for services, repositories, and data sources. Enforcing these rules prevents memory leaks and stale state across your Flutter application.

Why does GetIt throw a dependency not found error when I inject a new service?

GetIt throws a dependency not found error when registration order is incorrect or missing. Ensure your new service is explicitly registered in the AppInjector before resolving it, and verify all its dependencies are registered first.

What is the best way to structure a Flutter DI architecture to avoid common GetIt mistakes?

Structure your Flutter DI architecture by enforcing explicit typing, separating registrations into an AppInjector template, and following a step-by-step setup guide for services, network, data sources, and cubits.

Can I use GetIt to manage dependency injection for both network data sources and cubits?

Yes, GetIt manages dependency injection for both data sources and cubits. Register data sources and network services as lazy singletons, and register cubits as factories to ensure proper lifecycle management and safe dependency resolution.

Do I need to manually dispose of cubits when using GetIt for dependency injection?

Yes, you need to dispose of cubits when using GetIt dependency injection. Enforcing registerFactory for cubits ensures proper instance lifecycle management, and the AppInjector setup provides the necessary patterns for safe disposal.