kiwi_generator
4.2.1, released 2 years ago by gbtb16.com.br
Generates dependency injection code using the kiwi package.
What it does
Generates implementation code for abstract injector classes using annotations like @Register.factory and @Register.singleton. It integrates with build_runner to automate kiwi container registrations and reduce boilerplate.
AI-written summary of version 4.2.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are using the kiwi package for dependency injection and want to automate container setup
- You prefer annotation-based dependency injection generation using build_runner
Skip it when
- You prefer manual dependency registration without code generation
- You are using a different dependency injection framework like get_it or injectable
Strengths
- Reduces manual boilerplate code for kiwi container registrations
- Supports named factories, custom constructors, and type resolution mapping via annotations
Weaknesses
- Requires running build_runner for code generation
- Tied strictly to the kiwi dependency injection package ecosystem
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 9
Add build_runner and kiwi_generator to dev_dependencies, kiwi to dependencies, and run build_runner to generate code.
abstract class Injector {
@Register.singleton(ServiceA)
@Register.factory(Service, from: ServiceB)
void configure();
}Alternatives
Packages that do the same job and could replace kiwi_generator.
- injectable_generator
Alternative code-generation-based dependency injection tool typically used with get_it.
75Compare - get_it
Service locator pattern without mandatory code generation.
89Compare
Works with
Packages commonly used together with kiwi_generator: ones it builds on, ones built on it, and its own family.
- analyzerkiwi_generator depends on itPerforms static analysis of Dart code for tool integration and embedding.
- dart_stylekiwi_generator depends on itProvides an API and CLI to format Dart source code automatically.
- code_builderkiwi_generator depends on itA fluent, builder-based library for generating valid Dart code programmatically.
- built_collectionkiwi_generator depends on itImmutable collections based on SDK collections with builder pattern.
- buildkiwi_generator depends on itPackage for authoring build_runner compatible code generators.
- build_configkiwi_generator depends on itFormat definition and support for parsing build.yaml configuration.
- source_genkiwi_generator depends on itSource code generation builders and utilities for the Dart build system.
- kiwikiwi_generator depends on itA lightweight IoC container for Dart and Flutter that stores instances and factories in a Map.