CobaltInject class
Registers the annotated class in the generated container.
The class needs a public generative constructor; every parameter is resolved from the scope, and Named selects a named registration.
@cobaltInject
class Repository {
Repository(this.database);
final Database database;
}
- Annotations
-
- @Target.new({TargetKind.classType, TargetKind.method, TargetKind.getter})
Constructors
-
CobaltInject({CobaltLifetime lifetime = CobaltLifetime.lazySingleton, String? name, Type? exposeAs, Function? dispose, bool lazyInit = false, List<
Type> instantiations = const <Type>[], Type? scope}) -
Creates an annotation describing how the registration behaves.
const
Properties
- dispose → Function?
-
Closes the instance at teardown, for a type that cannot say how itself.
final
- exposeAs → Type?
-
Registers the class under this type instead of its own.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
instantiations
→ List<
Type> -
The instantiations of a generic class to register, one registration
each.
final
- lazyInit → bool
-
On a CobaltModule member returning a
Future, builds it on the firstgetAsyncinstead of duringscope.init()— the module form of@CobaltInit(lazy: true). On anything else it is a build error.final - lifetime → CobaltLifetime
-
How long the instance lives. Defaults to CobaltLifetime.lazySingleton.
final
- name → String?
-
Distinguishes this registration from others of the same type.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope → Type?
-
The
@CobaltChildScopemarker of the scope this is registered in, or null for the root.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited