Skip to content
pubscout

klizma

0.2.1, released 4 years ago by karapetov.com

A lightweight DI container for Dart with singleton and named factory support.

WASM-ready
$ flutter pub add klizma
Source repository

What it does

klizma provides a minimalistic dependency injection container that lets you register factories and singletons, then resolve them by type or name. It has no external dependencies and works on all Dart platforms.

AI-written summary of version 0.2.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need a simple, zero‑dependency DI solution for a small to medium project.
  • You want named factories to differentiate between multiple implementations of the same type.
  • You prefer a straightforward API without code generation or annotations.

Skip it when

  • You require advanced features like scoped lifetimes, automatic injection via annotations, or integration with Flutter widgets.
  • You need a full‑featured service locator with lifecycle management like get_it.

Strengths

  • Zero external dependencies
  • Supports named factories
  • Simple API
  • Works on all Dart platforms

Weaknesses

  • No code generation or annotations
  • Limited lifecycle control
  • No built‑in support for scoped or transient instances
  • No integration with Flutter widgets

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:klizma/klizma.dart';

final di = Klizma();
di.provide((_) => Engine('Vroom!'));
di.provide((_) => Horn('Honk!'));
di.provide((_) => Car(_<Engine>(), _<Horn>()));
final car = di.get<Car>();
print(car.sound);

Alternatives

Packages that do the same job and could replace klizma.

  • get_it

    Widely used, feature‑rich service locator with support for scopes, factories, and integration with Flutter.

  • injector

    Provides a similar lightweight DI container with optional code generation.

  • watch_it

    Offers a reactive DI container with change notification.