OnBuilder<T> class
Explicitly listenTo one or more injected state and reinvoke its onBuilder callback each time an injected state emits a notification.
For each OnBuilder widget flavor there is method like equivalent:
//Widget-like
OnBuilder(
listenTo: counter,
builder: () => Text('${counter.state}'),
),
//Method-like
counter.rebuild(
() => Text('{counter.state}'),
),
//
//Widget-like
OnBuilder.data(
listenTo: counter,
builder: (data) => Text('$data')),
),
//Method-like
counter.rebuild.onData(
(data) => Text(data),
),
//Widget-like
OnBuilder.all(
listenTo: counter,
onIdle: () => Text('onIdle'),
onWaiting: () => Text('onWaiting'),
onError: (err, errorRefresh) => Text('onError'),
onData: (data) => Text('$data'),
)
//Method-like
counter.rebuild.onAll(
onIdle: () => Text('onIdle'),
onWaiting: () => Text('onWaiting'),
onError: (err, errorRefresh) => Text('onError'),
onData: (data) => Text('$data'),
),
//
//Widget-like
OnBuilder.orElse(
listenTo: counter,
onWaiting: () => Text('onWaiting'),
orElse: (_) => Text('{counter.state}'),
),
//Method-like
counter.rebuild.onOrElse(
onWaiting: () => Text('onWaiting'),
orElse: (_) => Text('{counter.state}'),
),
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- OnBuilder
Constructors
-
OnBuilder({Key? key, InjectedBaseState<
T> ? listenTo, List<InjectedBaseState> ? listenToMany, required Widget builder(), SideEffects<T> ? sideEffects, bool shouldRebuild(SnapState<T> oldSnap, SnapState<T> newSnap)?, Object? watch()?, String? debugPrintWhenRebuild}) - Explicitly listenTo one or more injected state and reinvoke its onBuilder callback each time an injected state emits a notification.
-
OnBuilder.all({Key? key, InjectedBaseState<
T> ? listenTo, List<InjectedBaseState> ? listenToMany, Widget onIdle()?, required Widget onWaiting(), required Widget onError(dynamic error, void refreshError()), required Widget onData(T data), SideEffects<T> ? sideEffects, bool shouldRebuild(SnapState<T> oldSnap, SnapState<T> newSnap)?, Object? watch()?, String? debugPrintWhenRebuild}) - Explicitly listenTo one or more injected state and reinvoke its onBuilder callback each time an injected state emits a notification.
-
OnBuilder.create({Key? key, required ReactiveModel<
T> create(), required Widget builder(ReactiveModel<T> rm)}) -
factory
-
OnBuilder.data({Key? key, InjectedBaseState<
T> ? listenTo, List<InjectedBaseState> ? listenToMany, required Widget builder(T data), SideEffects<T> ? sideEffects, bool shouldRebuild(SnapState<T> oldSnap, SnapState<T> newSnap)?, Object? watch()?, String? debugPrintWhenRebuild}) - Explicitly listenTo one or more injected state and reinvoke its onBuilder callback each time an injected state emits a notification.
-
OnBuilder.orElse({Key? key, InjectedBaseState<
T> ? listenTo, List<InjectedBaseState> ? listenToMany, Widget onIdle()?, Widget onWaiting()?, Widget onError(dynamic error, void refreshError())?, Widget onData(T data)?, required Widget orElse(T data), SideEffects<T> ? sideEffects, bool shouldRebuild(SnapState<T> oldSnap, SnapState<T> newSnap)?, Object? watch()?, String? debugPrintWhenRebuild}) - Explicitly listenTo one or more injected state and reinvoke its onBuilder callback each time an injected state emits a notification.
Properties
- debugPrintWhenRebuild → String?
-
Debug print informative message on state notification.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
listenTo
→ InjectedBaseState<
T> ? -
State to listen to.
final
-
listenToMany
→ List<
InjectedBaseState> ? -
List of states to listenTo
final
-
onBuilder
↔ _On<
T> -
The part of the widget to rebuild on state notification.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shouldRebuild
→ (bool Function(SnapState<
T> oldSnap, SnapState<T> newSnap)?) -
Whether to rebuild the widget after state notification.
final
-
sideEffects
→ SideEffects<
T> ? -
Side effects to invoke.
final
- watch → (Object? Function()?)
-
Part of the state to watch, onRebuild will not be invoked unless the watched
param changes.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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}) → 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