Skip to content

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

License

Notifications You must be signed in to change notification settings

leonus96/injectzone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published