angel_container 1.0.0-alpha.11

  • Example
  • Installing
  • Versions
  • 60

container #

A better IoC container for Angel, ultimately allowing Angel to be used without dart:mirrors.

1.0.0-alpha.11 #

  • Added StaticReflector.

1.0.0-alpha.10 #

  • Added Container.registerLazySingleton<T>.
  • Added named singleton support.

1.0.0-alpha.9 #

  • Added Container.has<T>.

1.0.0-alpha.8 #

  • Fixed a bug where _ReflectedTypeInstance.isAssignableTo always failed.
  • Added @GenerateReflector annotation.

1.0.0-alpha.7 #

  • Add EmptyReflector.
  • ReflectedType.newInstance now returns a ReflectedInstance.
  • Moved ReflectedInstance.invoke to ReflectedFunction.invoke.

1.0.0-alpha.6 #

  • Add getField to ReflectedInstance.

1.0.0-alpha.5 #

  • Remove concrete type from ReflectedTypeParameter.

1.0.0-alpha.4 #

  • Safely handle void return types of methods.

1.0.0-alpha.3 #

  • Reflecting void in MirrorsReflector now forwards to dynamic.

1.0.0-alpha.2 #

  • Added ReflectedInstance.reflectee.

1.0.0-alpha.1 #

  • Allow omission of the first argument of Container.make, to use a generic type argument instead.
  • singleton -> registerSingleton
  • Add createChild, and support hierarchical containers.


import 'package:angel_container/angel_container.dart';
import 'package:angel_container/mirrors.dart';

void main() {
  // Create a container instance.
  var container = new Container(const MirrorsReflector());

  // Register a singleton.

  // You can also omit the type annotation, in which the object's runtime type will be used.
  // If you're injecting an abstract class, prefer the type annotation.
  // container.registerSingleton(Engine(40));

  // Register a factory that creates a truck.
  container.registerFactory<Truck>((container) {
    return _TruckImpl(container.make<Engine>());

  // Use `make` to create an instance.
  var truck = container.make<Truck>();

  // Register a named singleton.
  container.registerNamedSingleton('the_truck', truck);

  // Should print: 'Vroom! I have 40 horsepower in my engine.';

  // Should print the same.

  // We can make a child container with its own factory.
  var childContainer = container.createChild();

  childContainer.registerFactory<Truck>((container) {
    return _TruckImpl(Engine(5666));

  // Make a truck with 5666 HP.

  // However, calling `make<Engine>` will return the Engine singleton we created above.

abstract class Truck {
  void drive();

class Engine {
  final int horsePower;


class _TruckImpl implements Truck {
  final Engine engine;


  void drive() {
    print('Vroom! I have ${engine.horsePower} horsepower in my engine.');

Use this package as a library

1. Depend on it

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

  angel_container: ^1.0.0-alpha.11

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:angel_container/angel_container.dart';
Version Uploaded Documentation Archive
1.0.4 Apr 17, 2019 Go to the documentation of angel_container 1.0.4 Download angel_container 1.0.4 archive
1.0.3 Apr 17, 2019 Go to the documentation of angel_container 1.0.3 Download angel_container 1.0.3 archive
1.0.2 Apr 17, 2019 Go to the documentation of angel_container 1.0.2 Download angel_container 1.0.2 archive
1.0.1 Apr 10, 2019 Go to the documentation of angel_container 1.0.1 Download angel_container 1.0.1 archive
1.0.0 Nov 30, 2018 Go to the documentation of angel_container 1.0.0 Download angel_container 1.0.0 archive
1.0.0-alpha.12 Nov 8, 2018 Go to the documentation of angel_container 1.0.0-alpha.12 Download angel_container 1.0.0-alpha.12 archive
1.0.0-alpha.11 Nov 8, 2018 Go to the documentation of angel_container 1.0.0-alpha.11 Download angel_container 1.0.0-alpha.11 archive
1.0.0-alpha.10 Oct 22, 2018 Go to the documentation of angel_container 1.0.0-alpha.10 Download angel_container 1.0.0-alpha.10 archive
1.0.0-alpha.9 Aug 26, 2018 Go to the documentation of angel_container 1.0.0-alpha.9 Download angel_container 1.0.0-alpha.9 archive
1.0.0-alpha.8 Aug 21, 2018 Go to the documentation of angel_container 1.0.0-alpha.8 Download angel_container 1.0.0-alpha.8 archive

All 18 versions...

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 May 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15


Detected platforms: Flutter, web, other

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

Health issues and suggestions

Fix lib/src/empty/empty.dart. (-43.75 points)

Analysis of lib/src/empty/empty.dart failed with 2 errors:

line 50 col 13: Invalid constant value.

line 73 col 60: Invalid constant value.

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

Analysis of lib/angel_container.dart reported 3 hints:

line 35 col 18: Use = to separate a named parameter from its default value.

line 36 col 21: Use = to separate a named parameter from its default value.

line 37 col 19: Use = to separate a named parameter from its default value.

Maintenance suggestions

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <3.0.0
collection ^1.0.0 1.14.11
meta ^1.0.0 1.1.7
quiver ^2.0.0 2.0.3
Transitive dependencies
matcher 0.12.5
path 1.6.2
stack_trace 1.9.3
Dev dependencies
test any