EAP Dain

pub package license

A dynamic dependency injection framework for Dart developers.
The library is created inspired by "Koin". (Not all features are yet covered.)

Basic Usage

1. Create interface & implementation class.

Let's create interface class.

abstract class ExampleService {
  void sayHello();
}

Next, create implementation class.
At this time, implementation class should extend interfaces.

class ExampleServiceImpl extends ExampleService {
  @override
  void sayHello() {
    print("Hello World!");
  }
}

2. Create module class & declaring dependencies.

class ExampleModule extends Module {
  @override
  List<Bean> register() {
    return [
      single<ExampleService>(() => ExampleServiceImpl()),
    ];
  }
}

3. Register modules & inject class.

void main() {
  Dain.start([
    ExampleModule(),
  ]);

  final exampleModel = Dain.inject<ExampleService>();
  exampleModel.sayHello(); // print "Hello World!"
}

Advanced

WIP

Libraries

bean
bean_instance_creation_error
closed_scope_error
dain
factory
module
no_scope_found_error
scope
scope_already_exists_error
scope_id_not_allowed_null_error
scope_name_not_allowed_null_error
scope_resolver
scoped
single
singleton_scope