SuperBuilder class
A stateful widget that rebuilds its child widget when the Rx object changes.
The SuperBuilder widget allows you to rebuild a part of your UI in response to changes in an Rx object. It takes a builder callback function that receives a BuildContext and returns the widget to be built.
The builder callback will be invoked whenever the Rx object changes its state, triggering a rebuild of the widget. The Rx object can be accessed within the builder callback, allowing you to incorporate its state into your UI.
The buildWhen parameter is an optional condition that determines
whether the builder should be called when the Rx object changes.
If buildWhen evaluates to false, the builder will not be called,
and the child widget will not be rebuilt.
Example usage:
class CounterWidget extends SuperWidget {
const CounterWidget({super.key});
@override
Widget build(BuildContext context) {
final counter = 0.rx; // RxT<int>(0);
return SuperBuilder(
builder: (context) => Text(
"${counter.state}",
style: const TextStyle(fontSize: 25),
),
),
}
}
Note: Unless you specify an Id, you need to make use of an Rx object state in the builder method, otherwise, it will result in an error.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SuperBuilder
Constructors
- SuperBuilder({required RxBuilder builder, bool buildWhen()?, Key? key})
-
Creates a SuperBuilder widget.
const
Properties
- builder → RxBuilder
-
Called every time the Rx object changes state.
final
- buildWhen → bool Function()?
-
An optional condition that determines whether the builder should
be called when the Rx object changes. If buildWhen evaluates to
false, the builder will not be called, and the child widget will not be rebuilt.final - 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
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SuperBuilder> -
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