dardi 0.1.1

  • Readme
  • Changelog
  • Installing
  • 69

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.1.0 #

  • Initial version, with based implementation.

0.1.1 #

  • Added changelog.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dardi: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dardi/dardi.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
42
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
93
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Oct 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:dardi/dardi.dart.

Health suggestions

Fix lib/src/dardi.dart. (-1 points)

Analysis of lib/src/dardi.dart reported 2 hints:

line 12 col 7: DO use curly braces for all flow control structures.

line 14 col 7: DO use curly braces for all flow control structures.

Format lib/dardi.dart.

Run dartfmt to format lib/dardi.dart.

Maintenance suggestions

The package description is too short. (-7 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and dardi.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0