v6.2.1 Dart & Flutter · MIT licensed

Dependency injection,
wired at build time.

A lightweight, easy-to-use dependency injection container builder for Dart. Annotate your services with @Service and let build_runner generate the container for you.

$ dart pub add catalyst_builder catalyst_builder_contracts
lib/main.dart
import 'package:catalyst_builder/catalyst_builder.dart';
import 'main.catalyst_builder.plugin.g.dart';

@Service()
class ApiClient {
  ApiClient(this.config);
  final AppConfig config;
}

@GenerateServiceContainerPlugin(
  pluginClassName: 'AppPlugin',
)
void main() {
  final container = ServiceContainer()
    ..useAppPlugin()
    ..boot();

  // Fully wired – no manual factories.
  final api = container.resolve<ApiClient>();
}
6.2.1 Latest release
150/160 pub points
6 Platforms supported
MIT Open source license
✓ Verified publisher
HOW IT WORKS

Three steps from annotation to a fully wired app.

1 annotate

Mark your services

Decorate classes with @Service and your entry point with @GenerateServiceContainerPlugin.

@Service()
class UserRepository { … }
2 generate

Run build_runner

The builder writes a *.catalyst_builder.plugin.g.dart file next to your annotated entry point.

$ dart run build_runner build
3 boot

Boot the container

Create a ServiceContainer, register the generated plugin, boot it – then resolve anything.

container.useAppPlugin();
container.boot();
FEATURES

Everything you need. Nothing you have to wire by hand.

Built around SOLID principles and dependency inversion – so your app stays testable as it grows.

Compile-time generation

The container is generated with build_runner – no runtime reflection, a perfect fit for Flutter.

Annotation-driven

Declare services with @Service, or map them centrally with @ServiceMap.

Program to interfaces

Expose an implementation under its abstraction with exposeAs and swap it anytime.

Plugin architecture

Each package can ship its own generated container plugin – compose them in your root app.

Runs everywhere

Pure Dart and Flutter: Android, iOS, web, Windows, macOS and Linux.

Lightweight & open

Small footprint, full pub points, MIT licensed – use it in any project, commercial or not.

TWO PACKAGES

Generate where you need it. Depend on contracts everywhere else.

catalyst_builder Builder

Use it in your root package or a plugin package to generate the ServiceContainerPlugin.

pub.dev/packages/catalyst_builder →
catalyst_builder_contracts Contracts

Use it in packages that don't generate a container themselves but provide services that can be resolved.

pub.dev/packages/catalyst_builder_contracts →
QUICKSTART

Up and running in under a minute.

Add the packages, annotate your entry point, generate – done. The docs walk through a complete Flutter app.

1 · Install
$ dart pub add dev:build_runner \
    catalyst_builder catalyst_builder_contracts
2 · Annotate lib/main.dart
import 'package:catalyst_builder_contracts/catalyst_builder_contracts.dart';

@GenerateServiceContainerPlugin(pluginClassName: 'AppPlugin')
void main() { … }
3 · Generate & boot
$ dart run build_runner build
final container = ServiceContainer();
container.useAppPlugin();
container.boot();
runApp(const MainApp());

Let the builder do the wiring.
You write the app.

Free and open source. Star the repo, open an issue or send a pull request – contributions are welcome.