cobalt_annotations library
Annotations for Cobalt, a dependency injection framework for Dart and Flutter.
This library holds nothing but the markers the generator reads, so a
package that only declares annotations does not pull in the runtime. Most
applications import package:cobalt/cobalt.dart, which re-exports all of it.
Classes
- CobaltBootstrap
- Marks a phase-0 startup step, run before the container exists.
- CobaltChildScope
- Declares a scope shorter than the app, whose builder the generator writes.
- CobaltDecorates
- Wraps what the container hands out for target in the annotated class.
- CobaltEnvironment
- Restricts the annotated registration to an environment.
- CobaltHookAll
-
Adds the annotated
CobaltHookto the generated root scope — the generated form ofCobaltScope.hookAll. - CobaltInit
-
Registers the annotated class as an async singleton whose
init()is awaited duringscope.init(). - CobaltInject
- Registers the annotated class in the generated container.
- CobaltModule
- Marks a class whose members register types you did not write.
- CobaltParam
- Marks a constructor parameter as a value the call site supplies.
- CobaltProvided
- A registration the generated container does not make itself.
- CobaltScopeRoot
- Names the root scope and makes the generator emit a start function.
- Injected
- Fills the annotated field from the scope instead of from a constructor.
- Named
- Selects a named registration for the annotated parameter or field.
Enums
- CobaltLifetime
- How long an instance registered with CobaltInject lives.
Constants
- cobaltBootstrap → const CobaltBootstrap
- Marks a phase-0 startup step with the default order.
- cobaltHookAll → const CobaltHookAll
- Adds a hook to the generated root scope with the default order.
- cobaltInit → const CobaltInit
- Registers the class as an async singleton with no ordering constraints.
- cobaltInject → const CobaltInject
- Registers the class as a lazy singleton — one instance per scope, built on first use.
- cobaltLazyInit → const CobaltInit
-
Registers the class as an async singleton built by the first
getAsync. - cobaltModule → const CobaltModule
- Marks the class as a module of provider members.
- cobaltParam → const CobaltParam
-
The one you write:
@cobaltParam. - cobaltSingleton → const CobaltInject
- Registers the class as an eager singleton, built while the container is assembled.
- cobaltTransient → const CobaltInject
- Registers the class as a transient — a fresh instance per resolution, not retained by the scope.
- injected → const Injected
-
Fills the annotated
late finalfield from the scope.