A simple dependency injection library inspired by Google Guice. Currently the library supports advanced futures as providers, provider functions, custom scope contexts, binding listeners, scope listeners.


A simple usage example:

import "package:dartregistry/dartregistry.dart";

class ExampleModule extends RegistryModule {
  void configure() {
    // bind an instance
    bindInstance(Manager, new Manager());

    // bind a class implementation
    bindClass(Worker, Scope.ISOLATE, WorkerImpl);

    // bind a provider instance
    // bindProvider(Worker, Scope.ISOLATE, new WorkerProvider());

    // bind a provider function
    // bindProvideFunction(Worker, Scope.ISOLATE, () => new WorkerImpl());

class Manager {
  Worker worker;

  // @inject
  Provider<Worker> workerProvider;

  void test() {
    print("Manager test");

    // accessing directly

    // accessing through a provider

abstract class Worker {
  void run();

class WorkerImpl implements Worker {

  void init() {
    print("Worker bind");

  void deinit() {
    print("Worker unbind");

  void run() {
    print("Worker run");

class WorkerProvider implements Provider<Worker> {
  Worker get() => new WorkerImpl();

main() async {
  // load the configuration
  Registry.load(new ExampleModule());

  // run inside the isolate scope context
  await Registry.runInIsolateScope(() {
    // lookup an object by its interface
    var manager = Registry.lookupObject(Manager) as Manager;

    // lookups from in-scope bindings return the same instances
    var worker1 = Registry.lookupObject(Worker);
    var worker2 = Registry.lookupObject(Worker);
    assert(identical(worker1, worker2));

  // unload the configuration

Features and bugs

Please file feature requests and bugs at the issue tracker.