RxWidget<T> class

A lightweight bridge between Occam's reactive values and Flutter widgets.

RxWidget listens to the supplied _RxInterface (for example, an Rx<int> or RxList<String>) and rebuilds its builder whenever the underlying value changes. This keeps UI updates explicit—when the controller mutates the reactive value or calls refresh(), the widget rebuilds with the latest data.

class CounterLabel extends StatelessWidget {
  const CounterLabel({super.key, required this.counter});

  final Rx<int> counter;

  @override
  Widget build(BuildContext context) {
    return RxWidget<int>(
      notifier: counter,
      builder: (context, value) => Text('Count: $value'),
    );
  }
}

Prefer RxWidget for small pieces of UI that depend on a single reactive value. For larger widgets or multiple values, compose several RxWidgets or expose the controller directly in your StateWidget.

Inheritance

Constructors

RxWidget({Key? key, required RxInterface<T> notifier, required Widget builder(BuildContext context, T value)})
Creates an RxWidget that listens to notifier and hands the latest value to builder.
const

Properties

builder Widget Function(BuildContext context, T value)
Builds a widget every time notifier updates.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
notifier RxInterface<T>
The reactive value to observe for rebuilds.
final
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() RxWidgetState
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