SetupWidget class abstract
A base widget class that supports reactive setup and lifecycle hooks.
SetupWidget provides a declarative way to create reactive components that automatically track dependencies and update when those dependencies change.
Subclass SetupWidget to create a reusable widget component with:
- Reactive state management via setup method
- Lifecycle hooks for mount/unmount/update events
- Dependency injection via widget refs
- Automatic cleanup and dependency tracking
The setup widget lifecycle:
- Widget is created and createElement is called
- setup is invoked to initialize component logic and state
- Component is mounted and begins tracking dependencies
- Dependencies update triggers reactive re-rendering
- Widget unmounts and cleanup runs automatically
Example:
class MyWidget extends SetupWidget {
@override
Widget Function() setup() {
// Initialize reactive state and effects here
return () => Text('Hello');
}
}
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- SetupWidget
- Implementers
Constructors
-
SetupWidget({Key? key, WidgetRef<
SetupWidget> ? ref}) -
Creates a SetupWidget with an optional
keyandref.const
Properties
Methods
-
createElement(
) → SetupElement -
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
-
setup(
) → Widget Function() - The main setup function that defines the widget's build logic.
-
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