Skip to content
pubscout

kiwi_generator

4.2.1, released 2 years ago by gbtb16.com.br

Generates dependency injection code using the kiwi package.

$ flutter pub add kiwi_generator
Source repository

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.

Works with

Packages commonly used together with kiwi_generator: ones it builds on, ones built on it, and its own family.