dependencies_container 1.0.1
dependencies_container: ^1.0.1 copied to clipboard

A starting point for Dart libraries or applications.

Dependencies container written on pure dart

Documentation: in progress...

void main() {
  final container = DependenciesContainer(
      dependencies: {
        int: () => 5,
        String: () => '5',
      },
      lazySingletons: {String}
  );
  final str = container.dependency<String>(); // once created and returned
  final str2 = container.dependency<String>(); // already created and returned from cache
  // str and str2 are same instances
  container.clearSingleton<String>(); // removing from cache, next time call will return new one
  // not declared in singleton scope will return new one instance every time
  final integer = container.dependency<int>(); // once created
  final integer2 = container.dependency<int>(); // once created
  //integer and integer2 are different instances
}

0
likes
100
pub points
59%
popularity

A starting point for Dart libraries or applications.

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on dependencies_container