CorallineBuildContextAware mixin base
A mixin enabling a CoralComputation to receive BuildContext updates from a CoralWidget.
Business logic (Computations) often needs to resolve dependencies (like Theme, MediaQuery, or InheritedWidgets) requiring a BuildContext. Since Computations live outside the widget tree, CorallineBuildContextAware bridges this gap by providing a reactive context pipeline.
Design Philosophy: Leverages an 'Intent-Driven Architecture' via CorallineTerminalIntentAware. By routing the BuildContext as a topological intent from the UI layer to the business logic layer, the Computation remains decoupled from Flutter's widget lifecycle while still maintaining complete reactivity to dynamic UI changes (e.g., theme adjustments, screen resizing).
AI & Developer Note:
- Do not cache the BuildContext: Never save or store the emitted BuildContext inside local fields. Only map or derive values reactively using context's coral.
- Deadlock Warning: Ensure the Computation is mounted via a CoralWidget (using
.toWidget()); otherwise, the intent will not be delivered, and the context stream will remain empty, causing a deadlock.
Example:
class MyComponent extends CoralComponent with CorallineBuildContextAware {
late final themeCoral = context.map((ctx) => Theme.of(ctx));
@override
@manifestSync
Iterable<CoralNode> manifest() => [themeCoral];
@override
Widget build() {
final theme = themeCoral.data;
return Container(color: theme.primaryColor);
}
}
- Superclass constraints
- Mixin applications
Properties
-
context
→ Coral<
BuildContext> -
The reactive Coral node that exposes the current BuildContext stream.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
coralOf<
T> () → Coral< T> - Reactively subscribes to an ancestor InheritedCoralProviderWidget and unwraps its inner Coral<T> state.
-
dependOn<
T extends InheritedWidget> ({Object? aspect}) → Coral< T> -
Creates a reactive Coral pipeline subscribing to an InheritedWidget of type
Tfrom the element tree. -
didUpdateBuildContext(
BuildContext? oldContext, BuildContext? newContext) → void - Intercepts element tree lifecycle changes when the bound BuildContext transitions.
-
didUpdateIntent(
{CorallineTerminalIntent? oldIntent, CorallineTerminalIntent? newIntent}) → void -
Intercepts incoming terminal intents to extract and couple the BuildContext provider.
override
-
maybeCoralOf<
T> () → Coral< T?> - Reactively subscribes to an optional ancestor InheritedCoralProviderWidget and unwraps its inner Coral<T?> state.
-
maybeDependOn<
T extends InheritedWidget> ({Object? aspect}) → Coral< T?> -
Creates a null-safe reactive Coral pipeline subscribing to an optional InheritedWidget of type
T. -
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