dardi 0.1.1

Dart native js
Flutter Android iOS web

Simple DI library for flutter and pure dart projects.

Dardi #

Lightweight dependency Injection library based on service locator pattern with a terse interface.

main() async {
  //1) Register the necessary dependencies.
  Dardi.addSingleton(() => UserNetworkProvider());
  Dardi.addSingleton(() => UserMemoryProvider());

  //2) Register and get the necessary dependencies.
  Dardi.addDependency(() => UserRepository(
        Dardi.getDependency(),
        Dardi.getDependency(),
      ));

  var view = UserTerminalView();
  view.show();
}

class UserTerminalView {
  //3) And get the necessary dependencies.
  final UserRepository _repository = Dardi.getDependency();

  void show() async {
      ***
  }
}

Installation #

Add on pubspec.yml:

  dependencies:
    dardi: ^0.1.0

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0
likes
80
pub points
55%
popularity

Simple DI library for flutter and pure dart projects.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

baihu92@gmail.com

License

MIT (LICENSE)

More

Packages that depend on dardi