kiwi
5.0.1, released 2 years ago by gbtb16.com.br
A lightweight IoC container for Dart and Flutter that stores instances and factories in a Map.
WASM-ready
What it does
Kiwi lets you register instances, factories, and singletons, resolve them by type or name, and create scoped containers. It has no reflection overhead and supports optional code generation for faster registration.
AI-written summary of version 5.0.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a simple, fast DI container without reflection.
- You prefer a minimal API and want to avoid heavy frameworks.
- You want to use scoped containers for isolated parts of your app.
- You want optional code generation for boilerplate reduction.
Skip it when
- You need advanced dependency graph features like auto-wiring or lifecycle hooks.
- You require a full-featured state management solution beyond DI.
- You are building a very large application that needs a more mature DI framework.
Strengths
- Fast, no reflection, simple API
- Supports scoped containers and provider listing
- Optional code generation for boilerplate
- MIT license, cross-platform
Weaknesses
- Limited to basic DI patterns, no lifecycle management
- No built-in async support for factories
- Documentation is minimal compared to larger frameworks
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:kiwi/kiwi.dart';
final container = KiwiContainer();
container.registerInstance(Sith('Anakin', 'Skywalker'));
final sith = container.resolve<Sith>();Alternatives
Packages that do the same job and could replace kiwi.
Works with
Packages commonly used together with kiwi: ones it builds on, ones built on it, and its own family.