cobalt_flutter library

Flutter bindings for Cobalt.

Re-exports the whole runtime, so a Flutter app needs this import alone. CobaltScopeProvider publishes a scope to a subtree, CobaltScopeWidget owns one for as long as it is mounted, and context.cobalt<T>() resolves from whichever is nearest.

Classes

AsyncDisposable
Released asynchronously by the owning scope.
AsyncInitializable
Prepared asynchronously before the scope reports itself active.
CobaltApplication
Runs the two-phase startup and hands back the root scope.
CobaltAppScope
Owns the root scope for as long as the app is mounted.
CobaltAppScopeController
Restarts the root scope a CobaltAppScope owns.
CobaltAsyncBuilder<T extends Object>
Resolves T with getAsync and builds from it once it is there.
CobaltAsyncFactory<T extends Object>
Builds a T asynchronously, for registrations that need I/O before they are usable.
CobaltAsyncParamFactory<T extends Object, P extends Object>
Builds a T asynchronously from a runtime argument the container cannot supply.
CobaltAsyncParamOverride<T extends Object, P extends Object>
Replaces an async parameterized registration of T taking a P.
CobaltBootstrap
Marks a phase-0 startup step, run before the container exists.
CobaltBootstrapStep
A single unit of phase-0 work, run before the container exists.
CobaltChildScope
Declares a scope shorter than the app, whose builder the generator writes.
CobaltChildScopeBuilder
What the generator writes for an @CobaltChildScope class: a builder that knows which scope it builds and which it is declared to open under.
CobaltDecorates
Wraps what the container hands out for target in the annotated class.
CobaltDecorator<T extends Object>
Wraps what a registration of T produces, without touching the class.
CobaltDescribedFactory
A factory that names the class it builds, for descriptions of the graph.
CobaltDeveloperLogSink
Writes to dart:developer, which the SDK ships and every Dart tool reads.
CobaltDisposeFailure
One step of teardown that did not complete.
CobaltEnvironment
Restricts the annotated registration to an environment.
CobaltErrorObserver
Reports what the graph could not do, with the events that led up to it.
CobaltErrorReport
One failure, and what the graph was doing before it.
CobaltErrorSink
Where failures go.
CobaltFactory<T extends Object>
Builds a T synchronously.
CobaltHeldScope
Publishes the scope a CobaltScopeHolder holds to child, and shows absent while it holds nothing.
CobaltHook<T extends Object>
Runs on every instance of T a scope builds, and hands it on unchanged.
CobaltHookAll
Adds the annotated CobaltHook to the generated root scope — the generated form of CobaltScope.hookAll.
CobaltHookInfo
A hook added with CobaltScope.hookAll, as CobaltScope.hooks reports it.
CobaltInit
Registers the annotated class as an async singleton whose init() is awaited during scope.init().
CobaltInject
Registers the annotated class in the generated container.
CobaltInjectable
Receives its dependencies after construction rather than through its constructor.
CobaltKey
Identifies a registration inside a scope.
CobaltLogObserver
Turns Cobalt's events into log records and hands them to a sink.
CobaltLogRecord
One line a CobaltLogSink is asked to write.
CobaltLogSink
Where formatted Cobalt log records go.
CobaltModule
Marks a class whose members register types you did not write.
CobaltMultiSink
Writes every record to several sinks.
CobaltObserver
Watches what a scope tree does.
CobaltOverride<T extends Object>
Replaces the registration of T in the scope it is handed to.
CobaltParam
Marks a constructor parameter as a value the call site supplies.
CobaltParamFactory<T extends Object, P extends Object>
Builds a T from a runtime argument that the container cannot supply.
CobaltParamOverride<T extends Object, P extends Object>
Replaces a parameterized registration of T taking a P.
CobaltPrintLogSink
Writes to stdout with print.
CobaltProvided
A registration the generated container does not make itself.
CobaltRecordingObserver
Turns Cobalt's events into CobaltLogRecords and hands each to onRecord.
CobaltRegistrationInfo
What a scope knows about one registration, as CobaltScope.registrationOf reports it.
CobaltResolver
Reads instances out of a scope.
CobaltRootBuilder
A CobaltScopeBuilder for a root scope that also knows its name and its bootstrap steps.
CobaltScope
A container of registrations with a lifetime of its own.
CobaltScopeBuilder
Declares what goes into a scope.
CobaltScopedChild
Renders a CobaltScopedWidget's content below its scope.
CobaltScopedState<W extends CobaltScopedStatefulWidget>
State for a CobaltScopedStatefulWidget.
CobaltScopedStateChild
Renders a CobaltScopedState's content below its scope.
CobaltScopedStatefulWidget
A stateful widget that owns a scope for as long as it is mounted.
CobaltScopedWidget
A stateless widget that owns a scope for as long as it is mounted.
CobaltScopeHolder
Holds at most one child scope of parent at a time: a signed-in session, the open document, the selected account.
CobaltScopeProvider
Publishes a CobaltScope to a widget subtree.
CobaltScopeRef
Identifies a scope in a CobaltObserver callback.
CobaltScopeRoot
Names the root scope and makes the generator emit a start function.
CobaltScopeWidget
Owns a child scope for as long as it is mounted.
CobaltStartupObserver
Collects what a cold start spends its time on, for report.
CobaltStartupReport
What a cold start spent its time on, collected by CobaltStartupObserver.
CobaltStatefulScopeBuilder
Adapts a CobaltScopedStatefulWidget to CobaltScopeBuilder.
CobaltWidgetScopeBuilder
Adapts a CobaltScopedWidget to CobaltScopeBuilder.
Disposable
Released by the owning scope when it is disposed.
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

CobaltDisposeStage
Which part of teardown a failure came from.
CobaltEventKind
What happened, as a value rather than as prose.
CobaltLifetime
How long an instance registered with CobaltInject lives.
CobaltLogLevel
How much a log record matters.
CobaltRegistrationKind
What kind of registration a key has.
CobaltScopeState
Where a scope is in its lifecycle.

Extensions

CobaltBuildContext on BuildContext
Resolves dependencies from the nearest CobaltScopeProvider.

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 final field from the scope.

Functions

layeredTopologicalSort<T extends Object>(Iterable<T> nodes, CobaltDependenciesOf<T> dependenciesOf, {required String labelOf(T node)}) → List<List<T>>
Sorts nodes into dependency levels.

Typedefs

CobaltDependenciesOf<T> = Iterable<T> Function(T node)
Returns the nodes node must wait for.

Exceptions / Errors

CobaltAsyncParamError
Thrown when an async parameterized registration is resolved synchronously.
CobaltAsyncTransientError
Thrown when an async transient registration is resolved synchronously.
CobaltBootstrapError
Thrown when a phase-0 bootstrap step fails.
CobaltCycleError
Thrown when dependencies form a cycle.
CobaltDecoratorError
Thrown when a decorator cannot wrap what it was registered for.
CobaltDependsOnError
Thrown when dependsOn names something it cannot order.
CobaltDisposeError
Thrown when teardown finished but some of it did not go cleanly.
CobaltDuplicateRegistrationError
Thrown when the same key is registered twice in one scope.
CobaltError
Base class for everything Cobalt throws at runtime.
CobaltHookError
Thrown when a hook is added to a scope that has already built something.
CobaltInitTimeoutError
Thrown when init() runs past the timeout it was given.
CobaltLazyAsyncError
Thrown when a lazy async registration is read synchronously before it is built.
CobaltNoAppScopeError
Thrown when nothing owns a root scope above the widget asking to restart it.
CobaltNoScopeError
Thrown when nothing publishes a scope above the widget asking for one.
CobaltNotParameterizedError
Thrown when a parameterized resolve names a registration that takes no parameter.
CobaltNotReadyError
Thrown when an async singleton is requested before init() has built it.
CobaltNotRegisteredError
Thrown when nothing matching the requested key exists in the scope or any of its ancestors.
CobaltOverrideError
Thrown when an override replaces nothing, or cannot.
CobaltParamRequiredError
Thrown when a parameterized registration is resolved without its argument.
CobaltParamTypeError
Thrown when getWithParam is handed a value the registered factory cannot take.
CobaltScopeStateError
Thrown when a scope is used after it started disposing.
CobaltWarmUpError
Thrown by CobaltScope.warmUp when some of the builds it started failed.