ZenViewContextExtensions extension
Context extension for resolving a ZenController from within any widget.
Resolves strictly from the nearest ZenProvider ancestor in the widget tree. There is no global fallback — if no scope is found the call throws a ZenControllerNotFoundException with a clear, actionable message.
final ctrl = context.controller<MyController>();
For typed shorthand, define your own extension:
extension CartContextExt on BuildContext {
CartController get cart => controller<CartController>();
}
// Then in any widget:
context.cart.checkout();
- on
Methods
-
controller<
T extends ZenController> ({String? tag}) → T -
Available on BuildContext, provided by the ZenViewContextExtensions extension