SuperListener<T> class

A widget that calls the listener callback when the given rx object changes.

The SuperListener widget listens to changes in the provided rx object and calls the listener callback when the rx object changes its state.

The listener callback is called once when the rx object changes its state.

The child parameter is an optional child widget to be rendered by this widget.

The listenWhen parameter is an optional condition that determines whether the listener should be called when the rx object changes. If listenWhen evaluates to true, the listener will be called; otherwise, it will be skipped.

Example usage:

SuperListener<int>(
  listen: () => controller.count;
  listenWhen: (count) => count > 5,
  listener: (context) {
    // Handle the state change here
  }, // Only call the listener if count is greater than 5
  child: Text('Counter'),
)

Note: You need to make use of an Rx object state in the listen parameter, otherwise, it will result in an error.

Inheritance

Constructors

SuperListener.new({required RxCallback listener, required T listen(), Key? key, Widget? child, bool listenWhen(T state)?})
Creates a widget that rebuilds when the given rx object changes.
const

Properties

child Widget?
An optional child widget to be rendered by this widget.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
listen → T Function()
The state of the Rx object to listen to.
final
listener → RxCallback
Called once when the rx changes state.
final
listenWhen bool Function(T state)?
An optional condition that determines whether the listener should be called when the rx object changes. If listenWhen evaluates to true, the listener will be called; otherwise, it will be skipped. The listenWhen callback receives the current state of the rx object as an argument.
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() State<SuperListener<T>>
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