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

outdated

A dynamic dependency injection framework for Dart developers.

example/example.dart

import 'package:dain/bean/bean.dart';
import 'package:dain/dain.dart';
import 'package:dain/module/module.dart';

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

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

//Interface class
abstract class ExampleModel {
  void sayHello();
}

//Implementation class
class ExampleModelImpl extends ExampleModel {
  @override
  void sayHello() {
    print("Hello World!");
  }
}

//Bean registration class
class ExampleModule extends Module {
  @override
  List<Bean> register() {
    return [
      single<ExampleModel>(() => ExampleModelImpl()),
    ];
  }
}
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