RtWatcher
The RtWatcher
widget allows you to watch states and automatically rebuilds the widget tree whenever a monitored state changes.
Syntax
The RtWatcher
widget has two ways to use it:
- Using the default constructor:
- Using the Builder constructor:
Properties
key
: An optionalKey
to use for identifying the widget.child
: An optionalWidget
that remains static while the widget tree is rebuilt. Useful for parts of the UI that don’t depend on the watched states and can remain unchanged. It is passed to thebuilder
function if it is defined.-
builder
: A required function that returns a widget. This function is called whenever any of the states being watched change. It takes three parameters:context
: TheBuildContext
of theRtWatcher
widget.-
watch
: A function to watch the state that should trigger a rebuild when it changes. child
: Thechild
widget passed toRtWatcher
.
Usage
The following example demonstrates how to use the RtlWatcher
widget to listen for changes in a state and rebuild the widget tree accordingly.