dioc_generator 0.1.6

  • Readme
  • Changelog
  • Installing
  • 28

dioc_generator #

A generator of code for dioc containers.

Usage #

All registrations are made by annotating a partial bootstrapper class.

Various environments could be declared as methods that return a Container. You have to decorate these methods with Provide annotations to register dependencies.

library example;

import 'package:dioc/src/container.dart';
import 'package:dioc/src/built_container.dart';

part "example.g.dart";

@Provide.implemented(OtherService) // Default registration for all environments
abstract class AppBootstrapper extends Bootstrapper {

  @Provide(Service, MockService)
  Container development();

  @Provide(Service, WebService)
  Container production();

To indicate how to inject dependencies, you have two options : specifying a default mode, or declaring specific injections.

For a default inject mode, add it to the Provide constructor.

abstract class AppBootstrapper extends Bootstrapper {
  @Provide(Service, MockService, defaultMode: InjectMode.singleton)
  Container development();

Getting an instances and default injections will then use the default mode :

final service = container<Service>(); // singleton

Decorate your class fields with Inject annotations (and @inject, @singleton shortcuts) to declare specific injections.

class OtherService {
  final Service dependency;

  final Service dependency2;


To trigger code generation, run the command :

pub run build_runner build

Then simply use the provided builder to create your Container.

final container = AppBootstrapperBuilder.instance.development();

A complete example is also available.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Changelog #

0.0.1 #

  • Initial version

Use this package as a library

1. Depend on it

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

  dioc_generator: ^0.1.6

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

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

  • Dart: 2.7.1
  • pana: 0.13.4

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

Exceeded timeout of 0:02:00.000000

Health suggestions

Format lib/builder.dart.

Run dartfmt to format lib/builder.dart.

Format lib/dioc_generator.dart.

Run dartfmt to format lib/dioc_generator.dart.

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

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

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >2.0.0-dev <3.0.0