miodi 0.4.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 45

miodi #

Dependency Injection tools for Dart.

This library aims to easily manage dependencies in your business logic components.

The project is in beta testing, please write about all the errors found.

https://pub.dartlang.org/packages/miodi

Docs #

Documentation coming soon, please wait.

Example #

Added example project. Pls check for future updates for more information. https://github.com/Miolin/miodi/tree/master/example

You can make an injection into the constructors of your objects, there are no restrictions.

Create component:


class AppComponent extends MiodiComponent {
  final String param;

  AppComponent(this.param) : super([
    module([
      singleton(Database, () => DatabaseImpl()),
      factory(User, () => User()),
      factory(User, () => User(), name: 'provider_name'),
      ]),
      module([
        singleton(Logger, () => FileLogger(param), initOnStart: true),
        factory(LogSender, () => LogSender(get())),
      ])
  ]);
}

abstract class Database {}

class DatabaseImpl implements Database {}

class User {}

abstract class Logger {}

class FileLogger implements Logger {
  final String tag;
  FileLogger(this.tag);
}

class LogSender {
  final Logger logger;
  LogSender(this.logger);
}

In the body of the component, use the get() method to get dependencies (from the current or other modules). You can use several components. You can also use the component's constructor to represent dependencies in modules.

Usage example:

final appComponent = AppComponent('TAG');

void main() async {
  Miodi.init([appComponent]);

  Database database = Miodi.inject();
  //  or
  User user = inject();
  
  
  //and use 'injectAsync' if object creation takes time or requires delays
  Logger fileLogger = await Miodi.injectAsync();

  LogSender sender = Miodi.inject();
  sender.sendLog();
}

[0.4.0] - 05.11.2018

  • Add provider name. Support for providing the same types by different names.
  • Fixed init modules.
  • Fixed create custom modules.
  • Add singleton initOnStart params.

[0.3.1] - 05.11.2018

  • Remove scope providers.

[0.3.0] - 05.11.2018

  • Changed the work of scope objects
  • Changed inject method calls
  • Added the ability to extend the functionality of the library.

[0.2.5] - 05.11.2018

  • Added more information in readme

[0.2.4] - 05.11.2018

  • Added example project

[0.2.3] - 05.11.2018

  • Hotfix get dependency in component

[0.2.2] - 03.11.2018

  • Hotfix remove default scope, add optional delay before clear scope obj (delay in progress)

[0.2.1] - 03.11.2018

  • Add default scope, add optional delay before clear scope obj

[0.2.0] - 03.11.2018

  • Add custom scopes

[0.1.2] - 01.11.2018

  • Fix lib/miodi.dart

[0.1.1] - 01.11.2018

  • Miodi beta-version added correct errors

[0.0.1] - 01.11.2018

  • Miodi beta-version

example/README.md

example #

Example usage miodi Dependency Injection

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  miodi: ^0.4.0

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:miodi/miodi.dart';
  
Version Uploaded Documentation Archive
0.6.1 Jan 30, 2019 Go to the documentation of miodi 0.6.1 Download miodi 0.6.1 archive
0.5.2 Dec 22, 2018 Go to the documentation of miodi 0.5.2 Download miodi 0.5.2 archive
0.5.1 Dec 22, 2018 Go to the documentation of miodi 0.5.1 Download miodi 0.5.1 archive
0.4.0 Dec 16, 2018 Go to the documentation of miodi 0.4.0 Download miodi 0.4.0 archive
0.3.1 Dec 9, 2018 Go to the documentation of miodi 0.3.1 Download miodi 0.3.1 archive
0.3.0 Nov 24, 2018 Go to the documentation of miodi 0.3.0 Download miodi 0.3.0 archive
0.2.5 Nov 5, 2018 Go to the documentation of miodi 0.2.5 Download miodi 0.2.5 archive
0.2.4 Nov 5, 2018 Go to the documentation of miodi 0.2.4 Download miodi 0.2.4 archive
0.2.2 Nov 3, 2018 Go to the documentation of miodi 0.2.2 Download miodi 0.2.2 archive
0.2.1 Nov 3, 2018 Go to the documentation of miodi 0.2.1 Download miodi 0.2.1 archive

All 14 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
95
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

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

  • Dart: 2.3.1
  • pana: 0.12.16

Platforms

Detected platforms: Flutter, web, other

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

Health issues and suggestions

Document public APIs. (-1 points)

56 out of 56 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/core/module.dart. (-1.99 points)

Analysis of lib/core/module.dart reported 4 hints:

line 15 col 11: DO use curly braces for all flow control structures.

line 19 col 11: DO use curly braces for all flow control structures.

line 23 col 11: DO use curly braces for all flow control structures.

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

Fix lib/core/component.dart. (-1.49 points)

Analysis of lib/core/component.dart reported 3 hints:

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

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

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

Fix lib/miodi.dart. (-0.50 points)

Analysis of lib/miodi.dart reported 1 hint:

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

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/core/configuration.dart (Run dartfmt to format lib/core/configuration.dart.)
  • lib/core/consts.dart (Run dartfmt to format lib/core/consts.dart.)
  • lib/core/providers.dart (Run dartfmt to format lib/core/providers.dart.)
  • lib/error/errors.dart (Run dartfmt to format lib/error/errors.dart.)

Maintenance suggestions

The package description is too short. (-20 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
meta ^1.1.6 1.1.7
Dev dependencies
test ^1.5.0