dain 0.0.4 copy "dain: ^0.0.4" to clipboard
dain: ^0.0.4 copied to clipboard

outdated

A dynamic dependency injection framework for Dart developers.

[WIP] Dain #

https://img.shields.io/pub/v/dain https://img.shields.io/github/license/KazaKago/dain

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 and Declaring dependencies. #

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

3. Register modules and Inject class. #

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

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

Advanced #

[WIP]

0
likes
0
pub points
0%
popularity

Publisher

verified publisherkazakago.com

A dynamic dependency injection framework for Dart developers.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on dain