Listenable class abstract

An object that maintains a list of listeners.

The listeners are typically used to notify clients that the object has been updated.

There are two variants of this interface:

Many classes in the Flutter API use or implement these interfaces. The following subclasses are especially relevant:

The terms "notify clients", "send notifications", "trigger notifications", and "fire notifications" are used interchangeably.

See also:

  • AnimatedBuilder, a widget that uses a builder callback to rebuild whenever a given Listenable triggers its notifications. This widget is commonly used with Animation subclasses, hence its name, but is by no means limited to animations, as it can be used with any Listenable. It is a subclass of AnimatedWidget, which can be used to create widgets that are driven from a Listenable.
  • ValueListenableBuilder, a widget that uses a builder callback to rebuild whenever a ValueListenable object triggers its notifications, providing the builder with the value of the object.
  • InheritedNotifier, an abstract superclass for widgets that use a Listenable's notifications to trigger rebuilds in descendant widgets that declare a dependency on them, using the InheritedWidget mechanism.
  • Listenable.merge, which creates a Listenable that triggers notifications whenever any of a list of other Listenables trigger their notifications.
Implementers

Constructors

Listenable()
Abstract const constructor. This constructor enables subclasses to provide const constructors so that they can be used in const expressions.
const
Listenable.merge(List<Listenable?> listenables)
Return a Listenable that triggers when any of the given Listenables themselves trigger.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object notifies its listeners.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that the object notifies.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited