dice 1.0.3 copy "dice: ^1.0.3" to clipboard
dice: ^1.0.3 copied to clipboard

outdatedDart 1 only

Lightweight dependency injection framework for Dart.

Build Status

Dice #

Lightweight dependency injection framework for Dart.

Quick Guide #

  1. Add the folowing to your pubspec.yaml and run pub install
    dependencies:
      dice: any
  1. Create a module where you bind types to their instances
    class MyModule extends Module {
      @override
      configure() {
        // always returns the same instance
        bind(MyClass).toInstance(new MyClass());
        // invokes builder everytime type is requested
        bind(MyOtherClass).toBuilder(() => new MyOtherClass());
      }
    }
  1. Run it
    import "package:dice/dice.dart";
    main() {
      var injector = new Injector(new MyModule());
      var myClass = injector.getInstance(MyClass);
      var myOtherClass = injector.getInstance(MyOtherClass);
    }
0
likes
0
pub points
17%
popularity

Publisher

unverified uploader

Lightweight dependency injection framework for Dart.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta

More

Packages that depend on dice