ReactiveBuilder<T> class

ReactiveBuilder is a widget that listens to a ReactiveNotify and rebuilds itself whenever the value changes. It also provides an option to reset the state to its default value when the widget is disposed.

Example usage:

final connectionState = ReactiveNotify<ConnectionElement>(() => ConnectionElement.connected);

ReactiveBuilder<ConnectionElement>(
  valueListenable: connectionState,
  cleanStateOnDispose: true,
  builder: (context, value) {
    switch (value) {
      case ConnectionElement.error:
        return Container(child: Text('Un error Grave'), color: Colors.red);
      case ConnectionElement.connected:
        return Text("Está conectado");
      default:
        return Text('AMor eso no es');
    }
  },
);
Inheritance

Constructors

ReactiveBuilder.new({Key? key, required ValueListenable<T> valueListenable, void initState()?, void didChangeDependencies()?, void didUpdateWidget(ReactiveBuilder<T> oldWidget)?, void setState(void (VoidCallback fn))?, required Widget builder(T value), bool cleanStateOnDispose = false})
Creates a ReactiveBuilder.
const

Properties

builder Widget Function(T value)
The builder function which builds a widget depending on the valueListenable's value.
final
cleanStateOnDispose bool
A flag to determine if the state should be reset to its default value when the widget is disposed.
final
didChangeDependencies → void Function()?
The function to be executed during the didChangeDependencies lifecycle method of the widget. This allows for custom actions when the dependencies of the widget change, such as updates based on changes in InheritedWidgets or the BuildContext.
final
didUpdateWidget → void Function(ReactiveBuilder<T> oldWidget)?
The function to be executed during the didUpdateWidget lifecycle method of the widget. This function receives the old widget as an argument, allowing for comparison and custom logic when the widget updates in response to changes.
final
hashCode int
The hash code for this object.
no setterinherited
initState → void Function()?
The function to be executed during the initState lifecycle method of the widget. This allows for additional initialization logic or setup before the widget builds its UI.
final
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
setState → void Function(void (VoidCallback fn))?
The function that takes another function as an argument to update the widget's state. This allows for abstraction and customization of how the state is updated from outside the widget. The provided function should use the setState function to update the state.
final
valueListenable ValueListenable<T>
The ReactiveNotify whose value you depend on in order to build.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
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