Injector class abstract
Support for imperatively loading dependency injected services at runtime.
Injector is a simple interface that accepts a valid token (often either
a Type or OpaqueToken, but can be a custom object that respects equality
based on identity), and returns an instance for that token.
WARNING: It is not supported to sub-class this type in your own applications. There are hidden contracts that are not implementable by client code. If you need a mock-like implementation of Injector instead prefer using Injector.map.
- Implementers
Constructors
- Injector()
- 
          
            const
- Injector.empty()
- 
          Creates an injector that has no providers.
            constfactory
- 
          Injector.map(Map<Object, Object> providers, [Injector parent])
- 
          Create a new Injector that uses a basic map of token->instance.
            factory
Properties
- hashCode → int
- 
  The hash code for this object.
  no setterinherited
- runtimeType → Type
- 
  A representation of the runtime type of the object.
  no setterinherited
Methods
- 
  get(Object token, [Object? notFoundValue = throwIfNotFound]) → dynamic 
- 
  Returns an instance from the injector based on the provided token.
- 
  injectFromAncestry<T> (Object token) → T 
- 
  Injects and returns an object representing tokenfrom ancestors.
- 
  injectFromAncestryOptional(Object token, [Object? orElse = throwIfNotFound]) → Object? 
- 
  Injects and returns an object representing tokenfrom ancestors.
- 
  injectFromParent<T> (Object token) → T 
- 
  Injects and returns an object representing tokenfrom the parent.
- 
  injectFromParentOptional(Object token, [Object? orElse = throwIfNotFound]) → Object? 
- 
  Injects and returns an object representing tokenfrom the parent.
- 
  injectFromSelf<T> (Object token) → T 
- 
  Injects and returns an object representing tokenfrom this injector.
- 
  injectFromSelfOptional(Object token, [Object? orElse = throwIfNotFound]) → Object? 
- 
  Injects and returns an object representing tokenfrom this injector.
- 
  noSuchMethod(Invocation invocation) → dynamic 
- 
  Invoked when a nonexistent method or property is accessed.
  inherited
- 
  provideToken<T extends Object> (OpaqueToken< T> token) → T
- 
  Finds and returns an object instance provided for a token.
- 
  provideTokenOptional<T extends Object> (OpaqueToken< T> token) → T?
- 
  Finds and returns an object instance provided for a token.
- 
  provideType<T extends Object> (Type token) → T 
- 
  Finds and returns an object instance provided for a type token.
- 
  provideTypeOptional<T extends Object> (Type token) → T? 
- 
  Finds and returns an object instance provided for a type token.
- 
  provideUntyped<T> (Object token, [Object? orElse = throwIfNotFound]) → T 
- 
  Injects and returns an object representing token.
- 
  toString() → String 
- 
  A string representation of this object.
  inherited
Operators
- 
  operator ==(Object other) → bool 
- 
  The equality operator.
  inherited