witch_doctor 1.1.2 copy "witch_doctor: ^1.1.2" to clipboard
witch_doctor: ^1.1.2 copied to clipboard

A simple and intuitive dependency injection library for dart.

example/lib/example.dart

import 'package:witch_doctor/witch_doctor.dart';

import 'src/impl.dart';
import 'src/interface.dart';

void main() {
  // Creating container with name container_name_b
  TopHatContainer container = WitchDoctor.getContainer(name: "container_name");

  // Register <Interface, Implementation> passing the injection type and default args
  container.register<Interface>(
      InjectionType.factory, ImplPythonPoison(), [10, 20], {});

  // Load container
  WitchDoctor.load(name: "container_name");

  // Resolve instance using his interface
  Interface instance = WitchDoctor.resolve<Interface>();

  // Calling abstract method sum from implementation
  int value = instance.sum();

  print('value: $value');
}
3
likes
140
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

A simple and intuitive dependency injection library for dart.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

analyzer, build, source_gen

More

Packages that depend on witch_doctor