ZenView<T extends ZenController> class abstract

Base class for screens, pages, and widgets that consume a ZenController.

The Three-Step Pattern

1. Register  →  ZenProvider.create<T>(create: ...)   // route-level
                 ZenProvider(moduleBuilder: ...)      // feature module
                 Zen.put<T>(...)                      // app-level singleton

2. Consume   →  class MyPage extends ZenView<MyController>
                  → controller injected into build() automatically

3. React     →  ZenObserver / ZenUpdater / ZenQuery.when()

Controller Resolution

ZenView resolves its controller from the nearest ZenProvider ancestor in the widget tree. There is no global fallback — if no scope is found, a ZenControllerNotFoundException is thrown with a clear message telling you exactly what to add.

Standard Usage — Route-level controller

Wrap the view in ZenProvider.create at the router / navigation callsite:

// In your router:
ZenProvider.create<CartController>(
  create: () => CartController(),
  child: const CartPage(),
)

// The page — zero lookup code:
class CartPage extends ZenView<CartController> {
  const CartPage({super.key});

  @override
  Widget build(BuildContext context, CartController controller) {
    return ZenObserver(() => Text('${controller.itemCount.value} items'));
  }
}

Module Usage — Feature module with dependencies

ZenProvider(
  moduleBuilder: () => CartModule(),
  child: const CartPage(),
)

Which pattern to use?

Situation Pattern
App-level services (auth, analytics) Zen.registerModules([AppModule()]) at startup
Route/feature-level controllers ZenProvider.create<T>(create: ...) in router
Feature with dependencies ZenProvider(moduleBuilder: () => FeatureModule())
App-level singleton (prototyping) Zen.put<T>(...) at startup
Inheritance

Constructors

ZenView({Key? key})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tag String?
Optional tag for disambiguating multiple registrations of the same type.
no setter

Methods

build(BuildContext context, T controller) Widget
Build the widget with the injected controller.
createElement() Element
Inflates this configuration to a concrete instance.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited