Observer<T> class abstract

Observer is someone who observe something.

Technical speaking, Observer is an interface that has an onData method:

abstract class Observer<T> {
  void onData(T data);
}

Example:

final observer = Observer<int>((data) {
  print('onData: $data');
});

Above example create an Observer using inline onData method (data) { ... }. Then we can notify observer using observer.onData:

observer.onData(0); 
observer.onData(1);
observer.onData(2);

Prints:

onData: 0
onData: 1
onData: 2
Implementers

Constructors

Observer(OnData<T> onData)
Use Observer(...) to create an Observer with an inline onData method (data) { ... }.
const
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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onData(T data) → void
Use observer.onData to notify observer.
toString() String
A string representation of this object.
inherited

Operators

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