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 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>();
}Three steps from annotation to a fully wired app.
Mark your services
Decorate classes with @Service and your entry point with @GenerateServiceContainerPlugin.
@Service()
class UserRepository { … }Run build_runner
The builder writes a *.catalyst_builder.plugin.g.dart file next to your annotated entry point.
$ dart run build_runner buildBoot the container
Create a ServiceContainer, register the generated plugin, boot it – then resolve anything.
container.useAppPlugin();
container.boot();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.
Generate where you need it. Depend on contracts everywhere else.
Use it in your root package or a plugin package to generate the ServiceContainerPlugin.
Use it in packages that don't generate a container themselves but provide services that can be resolved.
pub.dev/packages/catalyst_builder_contracts →Up and running in under a minute.
Add the packages, annotate your entry point, generate – done. The docs walk through a complete Flutter app.
$ dart pub add dev:build_runner \
catalyst_builder catalyst_builder_contractsimport 'package:catalyst_builder_contracts/catalyst_builder_contracts.dart';
@GenerateServiceContainerPlugin(pluginClassName: 'AppPlugin')
void main() { … }$ dart run build_runner buildfinal 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.