injectzone 0.0.1 copy "injectzone: ^0.0.1" to clipboard
injectzone: ^0.0.1 copied to clipboard

A zone-based dependency injection package

injectzone

Injeczone is a simple and lightweight dependency injection library for Dart that allows you to override dependencies via your type.

Internally Injectzone uses zones and the zoneValues attribute to create or return injected dependencies.

Usage #

To use this package, add injectzone as a dependency in your pubspec.yaml file.

  1. Inject T dependency from builder function:

final deviceInfo = Injectzone().inject(() => DeviceInfoPlugin());

/// Note: [DeviceInfoPlugin] is a third party dependency
  1. Override T dependency with mock by ValueInjector during callback execution:
await Injectzone().withInjected([
  ValueInjector.inject<DeviceInfoPlugin>(mockDeviceInfoPlugin),
], () {
  ///... my test code
});

Features and bugs #

Please file feature requests and bugs at the issue tracker.

3
likes
140
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

A zone-based dependency injection package

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on injectzone