injectable_generator 0.2.2

injectable_generator #

A generator for injectable library.

ChangeLog #

[0.2.2]

  • remove flutter dependency
  • add support for custom initializers in register Modules
  • minor fixes

ChangeLog #

[0.2.1]

  • fix typo in @Environment annotation
  • ignore abstract classes in auto mode.

[0.2.0] Breaking Changes!

  • You now need to pass in your getIt instance to @initGetIt() func
  • Rename @Bind to @RegisterAs to avoid confusion because, now we're annotating the implementation not the abstract.
  • Add @factoryMethod annotation to mark named factories and static create methods.
  • Add @registerModule annotation to support registering third party types.
  • Fix eager singletons are registered before their dependencies.

[0.1.0]

  • initial release

example/README.md

Example #


import 'package:injectable/injectable_annotations.dart';

abstract class Service {}

@RegisterAs(Service, env: 'dev')
@injectable
class ServiceImpl1 extends Service {}

@RegisterAs(Service, env: 'prod')
@injectable
class ServiceImpl2 implements Service {

}

@injectable
class MyRepository {
  MyRepository(@Named.from(ServiceImpl1) Service service);
}

Use this package as a library

1. Depend on it

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


dependencies:
  injectable_generator: ^0.2.2

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:injectable_generator/injectable_generator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
94
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Document public APIs. (-0.37 points)

91 out of 93 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/dependency_resolver.dart. (-3.93 points)

Analysis of lib/dependency_resolver.dart reported 8 hints, including:

line 10 col 34: Avoid const keyword.

line 11 col 38: Avoid const keyword.

line 12 col 32: Avoid const keyword.

line 13 col 33: Avoid const keyword.

line 16 col 5: Avoid const keyword.

Fix lib/injectable_generator.dart. (-1.49 points)

Analysis of lib/injectable_generator.dart reported 3 hints:

line 12 col 33: Avoid const keyword.

line 13 col 35: Avoid const keyword.

line 54 col 7: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

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

Analysis of lib/injectable_config_generator.dart reported 1 hint:

line 13 col 33: Avoid const keyword.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
analyzer >=0.39.0 <0.40.0 0.39.4
build ^1.0.0 1.2.2
glob ^1.1.7 1.2.0
injectable ^0.2.2 0.2.2
source_gen ^0.9.0 0.9.4+7
Transitive dependencies
_fe_analyzer_shared 1.0.3
args 1.5.2
async 2.4.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
dart_style 1.3.3
html 0.14.0+3
js 0.6.1+1
logging 0.11.4
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pedantic 1.9.0
pub_semver 1.4.3
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
build_runner ^1.0.0