LView<T> class
A widget that consumes a LevitController and builds UI.
LView combines finding a controller and building a reactive widget tree.
When autoWatch is true (the default), buildView / builder run inside
an LWatch, so reactive reads rebuild the view automatically.
With autoWatch enabled, read reactives directly in buildView / builder.
Do not wrap the entire return value in another LWatch — that creates a
redundant outer watch. Use nested LWatch only for partial rebuilds, or set
autoWatch to false when you manage watching yourself.
Usage:
- Subclass:
class HomePage extends LView<HomeController> { @override Widget buildView(BuildContext context, HomeController controller) { return Text(controller.title()); } } - Builder:
LView<HomeController>( builder: (context, controller) => Text(controller.title()), );
- Inheritance
Constructors
-
LView({Key? key, T? resolver(BuildContext context)?, Widget builder(BuildContext context, T controller)?, Widget orElse(BuildContext context)?, bool autoWatch = true, List<
Object?> ? args}) -
Creates a view with a dependency factory and a builder.
const
-
LView.put(T create(), {Key? key, String? tag, bool permanent = false, required Widget builder(BuildContext context, T controller), Widget orElse(BuildContext context)?, bool autoWatch = true, List<
Object?> ? args}) -
Registers and consumes a dependency of type
T.factory -
LView.store(LevitStore<
T> state, {Key? key, required Widget builder(BuildContext context, T controller), Widget orElse(BuildContext context)?, bool autoWatch = true, List<Object?> ? args}) -
Syntax sugar for consuming a LevitStore.
factory
Properties
-
args
→ List<
Object?> ? -
Optional dependency keys for re-resolution.
final
- autoWatch → bool
-
Whether to wrap buildView / builder in an LWatch.
final
- builder → Widget Function(BuildContext context, T controller)?
-
Builds the widget tree using the resolved
controller.final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- orElse → Widget Function(BuildContext context)?
-
Fallback widget when the controller cannot be resolved.
final
- resolver → T? Function(BuildContext context)?
-
Resolves the dependency from the context.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildView(
BuildContext context, T controller) → Widget -
Builds the view content for the given
controller. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< LView< 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