ZenBuilder<T extends ZenController> class

Widget that automatically manages a ZenController's lifecycle

Features:

  • Finds existing controller or creates new one
  • Handles initialization and disposal
  • Rebuilds on controller updates
  • Supports scoped controllers
  • Automatically uses scope from context (e.g., ZenRoute)

Example:

ZenBuilder<MyController>(
  create: () => MyController(),
  builder: (context, controller) {
    return Text('Count: ${controller.count}');
  },
)
Inheritance

Constructors

ZenBuilder({Key? key, T create()?, required Widget builder(BuildContext context, T controller), String? tag, ZenScope? scope, bool? disposeOnRemove, void init(T controller)?, Widget onError(Object error)?, String? id})
const

Properties

builder → Widget Function(BuildContext context, T controller)
Builder function that receives the controller
final
create → T Function()?
Factory function to create the controller if not found
final
disposeOnRemove → bool?
Whether to dispose the controller when this widget is removed Default: true if controller is created by this widget, false otherwise
final
hashCode → int
The hash code for this object.
no setterinherited
id → String?
Optional update ID for selective rebuilds
final
init → void Function(T controller)?
Initialization callback called after controller is found/created
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onError → Widget Function(Object error)?
Error handler for build errors
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scope → ZenScope?
Optional scope for the controller If not provided, uses context scope (from ZenRoute) or root scope
final
tag → String?
Optional tag for finding/storing the controller
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<ZenBuilder<T>>
Creates the mutable state for this widget at a given location in the tree.
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