OnReactive class Null safety

First choice widget to listen to an injected state.

It explicitly register injected state consumed in its child widget tree.

Example:

final counter1 = RM.inject(()=> 0) // Or just use extension: 0.inj()
final counter2 = 0.inj();
int get sum => counter1.state + counter2.state;

//In the widget tree:
Column(
    children: [
        OnReactive( // Will listen to counter1
            ()=> Text('${counter1.state}');
        ),
        OnReactive( // Will listen to counter2
            ()=> Text('${counter2.state}');
        ),
        OnReactive(// Will listen to both counter1 and counter2
            ()=> Text('$sum');
        )
    ]
)
Inheritance

Constructors

OnReactive(Widget builder(), {bool shouldRebuild(SnapState oldSnap, SnapState newSnap)?, SideEffects? sideEffects, String? debugPrintWhenRebuild, String? debugPrintWhenObserverAdd, Key? key})
First choice widget to listen to an injected state. [...]
const

Properties

builder Widget Function()
Widget tree to rebuild when any of subscribed state emits notification.
final
debugPrintWhenObserverAdd String?
Debug print an informative message when a state is added to the list of subscription.
final
debugPrintWhenRebuild String?
Debug print an informative message when the widget is rebuild with the name of the state that has emitted the notification.
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
shouldRebuild → (bool Function?(SnapState oldSnap, SnapState newSnap)?)
Whether to rebuild the widget after a state emits notification. [...]
final
sideEffects SideEffects?
Side effects to be invoked
final

Methods

build(BuildContext context) Widget
override
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() → _ReactiveStatelessWidgetState
Creates the mutable state for this widget at a given location in the tree. [...]
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
didAddObserverForDebug(List<InjectedBaseState> observers) → void
Called in debug mode only when an state is added to the list of listeners
override
didMountWidget() → void
Called when the widget is first inserted in the widget tree
override
didNotifyWidget(SnapState snap) → void
Called when the widget is notified to rebuild, it exposes the SnapState of the state that emits the notification
override
didUnmountWidget() → void
Called when the widget is removed from the widget tree
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
shouldRebuildWidget(SnapState oldSnap, SnapState currentSnap) bool
Condition on when to rebuild the widget, it exposes the old and the new SnapState of the the state that emits the notification.
override
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}) 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. [...]
@nonVirtual, inherited