Overview
Inject_generator is a build-time source code generator for the inject_annotation package, enabling dependency injection in Flutter and Dart applications. It processes annotations like @inject, @component, and @module to automatically generate fully wired dependency components, reducing boilerplate and improving compile-time safety. By generating code during the build process, it ensures efficient and type-safe dependency resolution without runtime overhead. The tool integrates seamlessly with Flutter and supports multiple platforms including Android, iOS, Linux, macOS, and Windows.
Use cases
- Automating dependency injection setup
- Reducing manual wiring of dependencies
- Enabling compile-time dependency validation
- Streamlining large-scale app architecture
- Supporting modular application design
Key features
- Build-time code generation
- Compile-time dependency safety
- Minimal runtime overhead
- Support for @inject, @component, and @module
- Seamless integration with inject_annotation
Suitable for
- Large Flutter/Dart projects
- Teams prioritizing maintainability
- Applications using dependency injection patterns
- Developers avoiding runtime reflection
- Projects requiring type-safe DI
Considerations
- Requires build_runner to be set up
- Needs proper annotation usage
- Generated code must be committed or regenerated on each build
- Limited to static dependency graphs
- Not suitable for dynamic dependency resolution