WatchAll class

WatchAll

A dynamic widget designed to rebuild itself in response to changes in multiple Listenable objects. It listens to a collection of watchers, each being a Listenable object. This includes custom Watcher instances as well as other Listenable types available in Flutter.

WatchAll offers a practical approach for reactive UI updates. It triggers a rebuild whenever any of the specified watchers notify their listeners of changes, ensuring an up-to-date UI.

Inheritance

Constructors

WatchAll({required List<Listenable?> watchers, required Widget builder(BuildContext context), bool watchWhen()?, Duration? threshold, Key? key})
const

Properties

builder Widget Function(BuildContext context)
A function that defines the widget to be built based on the current context. This function is called whenever the widget needs to rebuild, providing the flexibility to design responsive and dynamic UI components that react to state changes.
final
hashCode int
The hash code for this object.
no setterinherited
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
threshold Duration?
An optional Duration that sets a time limit for how frequently the widget can rebuild in response to watchers notifications. If set, the widget will only consider rebuilding after this duration has elapsed since the last rebuild, providing a way to limit the frequency of rebuilds during rapid state changes. This feature is particularly useful for optimizing performance and avoiding flickering in the UI.
final
watchers List<Listenable?>
A list of Listenable objects that this widget is listening to. The widget will be rebuilt when any of the watchers notify their listeners. This list can include any mix of Watcher instances or other Listenable types, making it flexible for different use cases.
final
watchWhen → (bool Function()?)
An optional callback that determines whether the widget should rebuild when any of the watchers notify their listeners. It can be used to optimize performance by preventing unnecessary rebuilds. If it returns true, the builder function is called to rebuild the widget. If false, the widget is not rebuilt. If left null, the widget rebuilds on every notification from the watchers.
final

Methods

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