dm_gen 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 52

dm_gen #

Dependency manager like dagger from android. This package can also create an instance of a class from a reference to the constructor and dependency area

Example #

Code from example/

Create abstract class with annotation @Modules({{you module list}}) for dependency call

    @Modules([CacheModule, DbModule, NetworkModule])
    abstract class Dm {

      static Future<Dm> init() {
        return DmImpl().init();
      }

      @provide
      DB db();

      CommonConsumer commonConsumer ();

      MarkInjectConsumer markInjectConsumer();

      WithParameterConsumer withParameterConsumer(String name);
    }

The @Modules annotation contains classes with @provide methods tagged that will be available for calling in other modules and consumers.

    class CacheModule {
      @provide
      @singleton
      Cache cacheModule(DB db, Network<String> network) => Cache(db, network);
    }

This function may contain parameters with types that will be taken from other modules

Dependency can get from module or can creating from first or marked @inject constructor in returned class like this

    class MarkInjectConsumer {
      DB db;
      Cache cache;

      MarkInjectConsumer();

      @inject
      MarkInjectConsumer.cached(this.db, this.cache);
    }

[0.1.0] - 29.02.2020. #

  • Initial release.

[0.1.1] - 04.04.2020. #

  • fix generic types.

example/lib/main.dart

library example;

/// A Calculator.
class Calculator {
  /// Returns [value] plus 1.
  int addOne(int value) => value + 1;
}

Use this package as a library

1. Depend on it

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


dependencies:
  dm_gen: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


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

We analyzed this package on Jun 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Health issues and suggestions

Document public APIs. (-1 points)

2 out of 2 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/src/generator.dart. (-0.50 points)

Analysis of lib/src/generator.dart reported 1 hint:

line 98 col 12: Don't explicitly initialize variables to null.

Format lib/src/error/module_have_invalid_constructor.dart.

Run dartfmt to format lib/src/error/module_have_invalid_constructor.dart.

Format lib/src/error/not_provide.dart.

Run dartfmt to format lib/src/error/not_provide.dart.

Format lib/src/model/consumer.dart.

Run dartfmt to format lib/src/model/consumer.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.6.0 <3.0.0
analyzer ^0.39.4 0.39.10
build ^1.2.2 1.3.0
build_runner ^1.7.3 1.10.0
dm ^0.1.0 0.1.0
source_gen ^0.9.4+7 0.9.5
Transitive dependencies
_fe_analyzer_shared 4.0.0
args 1.6.0
async 2.4.1
build_config 0.4.2
build_daemon 2.1.4
build_resolvers 1.3.9
build_runner_core 5.2.0 6.0.0
built_collection 4.3.2
built_value 7.1.0
charcode 1.1.3
checked_yaml 1.0.2
code_builder 3.3.0
collection 1.14.12
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
dart_style 1.3.6
fixnum 0.10.11
glob 1.2.0
graphs 0.2.0
html 0.14.0+3
http_multi_server 2.2.0
http_parser 3.1.4
io 0.3.4
js 0.6.1+1
json_annotation 3.0.1
logging 0.11.4
matcher 0.12.6
meta 1.1.8
mime 0.9.6+3
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
path 1.7.0
pedantic 1.9.0
pool 1.4.0
pub_semver 1.4.4
pubspec_parse 0.1.5
quiver 2.1.3
shelf 0.7.5
shelf_web_socket 0.2.3
source_span 1.7.0
stack_trace 1.9.3
stream_channel 2.0.0
stream_transform 1.2.0
string_scanner 1.0.5
term_glyph 1.1.0
timing 0.1.1+2
typed_data 1.1.6
watcher 0.9.7+15
web_socket_channel 1.1.0
yaml 2.2.1