utopia_di 0.3.1 copy "utopia_di: ^0.3.1" to clipboard
utopia_di: ^0.3.1 copied to clipboard

Light & Fast Dart Dependency Injection library. Easy to use and powerful for all kinds of needs, with no external dependencies.

Utopia Dependency Injection #

Light & Fast Dart Dependency Injection Library

Features #

  • Dependency injection

Getting started #

Add dependency

dependencies:
    utopia_di: <latest>
copied to clipboard

Usage #

It's very simple to use. Use it by creating a instance or use a singleton instance from the library.

import 'package:utopia_di/utopia_di.dart';

final di = DI(); //you can also use `DI.instance` or `DI.i`

void main() {
  di.setResource('resource1', () => 'this is resource 1');
  di.setResource('number1', () => 10);
  di.setResource(
    'dependentResource',
    (String resource1, int number1) => '$resource1 and $number1',
    dependencies: ['resource1', 'number1'],
  );

  print(di.getResource('resource1'));
  print(di.getResource('number1'));
  print(di.getResource('dependentResource'));
}
copied to clipboard

The MIT License (MIT) https://www.opensource.org/licenses/mit-license.php

2
likes
150
points
213
downloads

Publisher

verified publisherappwriters.dev

Weekly Downloads

2024.08.22 - 2025.03.06

Light & Fast Dart Dependency Injection library. Easy to use and powerful for all kinds of needs, with no external dependencies.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on utopia_di