LScopedView<T> class
A widget that manages its own dependency scope and builds a view.
LScopedView creates a new LevitScope for its subtree, registers dependencies via dependencyFactory / onConfigScope, and then builds the UI using LView. When the widget is unmounted, the scope and all its dependencies are disposed.
Sub-classing with onConfigScope is a first-class pattern alongside
LScopedView.put. With autoWatch true (default), read reactives directly
in buildView; do not wrap the entire return in LWatch.
// Example usage:
LScopedView<ProfileController>.put(
() => ProfileController(),
builder: (context, controller) => ProfilePage(controller),
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- LView<
T> - LScopedView
Constructors
-
LScopedView({Key? key, LScopeDependencyFactory? dependencyFactory, T? resolver(BuildContext context)?, Widget builder(BuildContext context, T controller)?, Widget orElse(BuildContext context)?, bool autoWatch = true, String? scopeName, List<
Object?> ? args}) -
const
-
LScopedView.put(T create(), {Key? key, String? tag, bool permanent = false, required Widget builder(BuildContext context, T controller), Widget orElse(BuildContext context)?, bool autoWatch = true, String? scopeName, List<
Object?> ? args}) -
Shorthand for creating a scope, immediately registering a dependency, and consuming it.
factory
-
LScopedView.store(LevitStore<
T> state, {Key? key, LScopeDependencyFactory? dependencyFactory, required Widget builder(BuildContext context, T controller), Widget orElse(BuildContext context)?, bool autoWatch = true, String? scopeName, List<Object?> ? args}) -
Syntax sugar for consuming a LevitStore within a new scope.
factory
Properties
-
args
→ List<
Object?> ? -
Optional dependency keys for re-resolution.
finalinherited
- autoWatch → bool
-
Whether to wrap buildView / builder in an LWatch.
finalinherited
- builder → Widget Function(BuildContext context, T controller)?
-
Builds the widget tree using the resolved
controller.finalinherited - dependencyFactory → LScopeDependencyFactory?
-
Optional factory to register dependencies in the internal scope.
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.
finalinherited
- resolver → T? Function(BuildContext context)?
-
Resolves the dependency from the context.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scopeName → String?
-
A descriptive name for the internal scope.
final
Methods
-
buildView(
BuildContext context, T controller) → Widget -
Builds the view content for the given
controller.inherited -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< LScopedView< 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
-
onConfigScope(
LevitScope scope) → void - Called when the internal scope is being configured.
-
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