context property

  1. @protected
Coral<BuildContext> get context

The reactive Coral node that exposes the current BuildContext stream.

Used to derive child Coral nodes that react to UI context changes such as theme, localization, or media query updates.

Constraints & Behavior: Every access to context invokes _contextProvider.coral, creating a new distinct broadcaster line node instance.

AI & Developer Note (Broadcaster Line Warning):

  • Reading context repeatedly or inside compute() without caching creates separate unattached or dormant line instances.
  • Pulling data from an unattached line node will fail with a state error (CoralBroadcasterLineDormantAccessError).
  • Best Practice: Always cache derived nodes in late final fields or store the context instance before registering it in manifest.

Example:

class MyComponent extends CoralComponent with CorallineBuildContextAware {
  // Correct: Cache the derived line node as a late final field.
  late final themeCoral = context.map((ctx) => Theme.of(ctx));

  @override
  @manifestSync
  Iterable<CoralNode> manifest() => [themeCoral];
}

Implementation

@protected
Coral<BuildContext> get context => _contextProvider.coral;