injectable_generator 0.3.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

injectable_generator #

A generator for injectable library.

ChangeLog #

[0.3.3] #

  • fix duplicate var names issue when pre-resolving multiple instances of the same type

[0.3.2] #

  • fix registered abstract dependencies are reported missing.
  • fix registering third party types as singleton throws an error.

[0.3.1] #

  • fix resolve by instanceName is using positional var instead of named
  • fix part files are imported as stand alone
  • minor fixes

[0.3.0] Breaking Changes! #

  • add support for GetIt 4.0.0
  • fix generic types are registered as dynamic
  • fix unresolved future when registering asynchronous dependencies
  • change asynchronous dependencies will be registered using async factory unless annotated with @preResolve

[0.2.4] #

  • fix type arguments are not imported.
  • fix get with instanceName missing type.

[0.2.3] #

  • improve support for custom initializers
  • fix src import issue

[0.2.2] #

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

[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.3.3

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]
76
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Document public APIs. (-0.60 points)

145 out of 147 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/injectable_generator.dart. (-0.50 points)

Analysis of lib/injectable_generator.dart reported 1 hint:

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
analyzer >=0.39.2 <0.40.0 0.39.4
build ^1.0.0 1.2.2
glob ^1.1.7 1.2.0
injectable ^0.3.0 0.3.0
source_gen ^0.9.0 0.9.5
Transitive dependencies
_fe_analyzer_shared 1.0.3
args 1.6.0
async 2.4.1
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.9.3
path 1.6.4
pedantic 1.9.0
pub_semver 1.4.4
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+14
yaml 2.2.0
Dev dependencies
build_runner ^1.0.0