auto_injector
2.2.0, released 5 months ago by flutterando.com.br
Automatic dependency injection system for Dart and Flutter without build_runner.
What it does
Allows registering factories, singletons, lazy singletons, and instances without requiring code generation. It automatically analyzes and injects constructor parameters and supports modularization.
AI-written summary of version 2.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want automatic dependency injection without build_runner overhead
- You are building a modular Flutter or Dart application
- You need automatic parameter injection for constructors
Skip it when
- You prefer compile-time dependency injection safety via code generation
- Your architecture strictly requires a different DI container like get_it or injectable
Strengths
- No build_runner required
- Supports modularization and hierarchical injectors
- Handles automatic parameter injection and bind configuration
Weaknesses
- Relies on runtime reflection/analysis instead of compile-time code generation
- Fewer community packages or extensions compared to older established alternatives like get_it
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 2
final autoInjector = AutoInjector();
void main() {
autoInjector.add(Controller.new);
autoInjector.addSingleton(Datasource.new);
autoInjector.commit();
final controller = autoInjector.get<Controller>();
}Alternatives
Packages that do the same job and could replace auto_injector.
- get_it
If you prefer a manual service locator approach without reflection overhead.
89Compare - injectable
If you prefer build_runner and compile-time annotations for dependency injection.
78Compare
Works with
Packages commonly used together with auto_injector: ones it builds on, ones built on it, and its own family.
- uuidauto_injector depends on itGenerates and parses RFC‑4122/9562 UUIDs (v1‑v8) for Dart.
- flutter_modularBuilt on auto_injectorModular route management and dependency injection organized by feature.
- modular_coreBuilt on auto_injectorInjection system and routes for flutter_modular and shelf_modular
- vadenBuilt on auto_injectorA Dart backend framework inspired by Spring Boot, using annotations for controllers, DI, and OpenAPI docs.