A base component for assembling declarative UI Widget subtrees from multiple reactive dependencies (N:1).
BuildComponent bridges Coralline's reactive state computation with Flutter's declarative layout system by exposing a Flutter-friendly build method.
Design Philosophy:
This class encapsulates the ComplexComputation computation contract to provide a familiar,
Flutter-like developer experience (build()). However, it remains a true reactive node within
Coralline's topological pipeline rather than a Flutter Widget. It computes the UI subtree lazily
when marked dirty by its reactive dependencies.
AI & Developer Note:
- Implement build instead of overriding compute. The compute method is marked
@nonVirtualand forwards directly to build. - Do not store dynamic UI state in local mutable fields. Always derive UI declaratively from reactive Coral streams to maintain topological purity and prevent state synchronization bugs.
- Ensure all reactive dependencies accessed within build are declared in manifest.
- For single-dependency (1:1) UI components, consider using SimplexBuildComponent for zero-allocation performance.
Example:
base class CounterViewComp extends BuildComponent {
CounterViewComp({required this.count});
final Coral<int> count;
@override
@manifestSync
Iterable<CoralNode> manifest() => [count];
@override
Widget build() {
return Text('Count: ${count.data}');
}
}
- Inheritance
-
- Object
- CoralComputation<
Widget> - ComplexComputation<
Widget> - BuildComponent
- Available extensions
Constructors
Properties
-
coral
→ Coral<
Widget> -
Exposes the underlying topological node that powers this computation.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isActivated → bool
-
Indicates whether the underlying topological node is currently active in the graph.
no setterinherited
- isDeactivated → bool
-
Indicates whether the underlying topological node is currently deactivated.
no setterinherited
- isPaused → bool
-
Indicates whether the underlying topological node is currently in a paused state.
no setterinherited
- isRunning → bool
-
Indicates whether the underlying topological node is running and processing events.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
) → Widget - Builds the declarative UI Widget subtree based on the reactive state.
-
compute(
) → Widget -
Performs the actual computation and returns the new value for this node based on the upstream dependencies.
override
-
iterateInbound(
) → Iterable< CoralNode> -
Iterates over all direct upstream inbound nodes connected to this computation.
inherited
-
manifest(
) → Iterable< CoralNode> -
Declares all upstream reactive dependency CoralNodes that power this component.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
toWidget(
{Key? key, Widget errorBuilder(BuildContext context, Object error, StackTrace? stackTrace)?}) → CoralWidget -
Available on T, provided by the CoralComputationWidgetExtension extension
Converts this Computation into a strongly-typed CoralWidget. -
toWidget(
{Key? key, Widget errorBuilder(BuildContext context, Object error, StackTrace? stackTrace)?}) → CoralWidget -
Available on CoralProvider<
Converts this CoralProvider into a CoralWidget.Widget> , provided by the CoralWidgetProviderExtension extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited