dependOn<T extends InheritedWidget> method
Creates a reactive Coral pipeline subscribing to an InheritedWidget of type T from the element tree.
aspect: Optional aspect identifier for fine-grained dependency tracking whenTis an InheritedModel.
Requires:
- An ancestor InheritedWidget of type
Tmust exist in the element tree when the pipeline is evaluated.
Ensures:
- Automatically triggers
didChangeDependenciesand re-computes the pipeline wheneverT(oraspect) updates. - Returns a non-null reactive Coral<T> pipeline emitting instances of
T.
Throws:
- Throws a null assertion error if no ancestor InheritedWidget of type
Tis found. Use maybeDependOn if optional.
Example:
class MyComponent extends ComplexComputation<Widget> with CorallineBuildContextAware {
late final themeCoral = dependOn<ThemeWidget>();
}
Implementation
@protected
@pragma('vm:prefer-inline')
Coral<T> dependOn<T extends InheritedWidget>({Object? aspect}) {
return context
.map((e) => e.dependOnInheritedWidgetOfExactType<T>(aspect: aspect)!)
.distinct();
}