AsyncNotifier<T> class

A ValueNotifier<T> that listens to Future and Stream snapshot.

Inheritance
Mixed-in types
Available extensions

Constructors

AsyncNotifier({T? data, Object? error, StackTrace stackTrace = StackTrace.empty, ConnectionState state = ConnectionState.none, bool? cancelOnError})
Creates an AsyncNotifier instance with an initial value of type T.

Properties

cancelOnError bool?
Whether the subscription should be canceled when an error occurs.
final
connectionState ConnectionState
Current state of connection to the asynchronous computation.
no setterinherited
data → T?
The latest data received by the asynchronous computation.
no setterinherited
error Object?
The latest error object received by the asynchronous computation.
no setterinherited
errorMessage String?

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Returns the error message if the error is an Exception with a message, otherwise returns the string representation of the error.
no setter
errorMessage String?

Available on AsyncSnapshot<T>, provided by the FlutterAsyncSnapshotExtension extension

The error message of this AsyncSnapshot.error.
no setter
future Future<T>?
The Future currently being listened to.
getter/setter pair
hasData bool
Returns whether this snapshot contains a non-null data value.
no setterinherited
hasError bool
Returns whether this snapshot contains a non-null error value.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hasNone bool

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Returns whether this snapshot has neither data/error.
no setter
isLoading bool

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Returns whether this snapshot is computing.
no setter
isReloading bool

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Returns whether this snapshot is computing and has data/error.
no setter
requireData → T
Returns latest data received, failing if there is no data.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTrace StackTrace?
The latest stack trace object received by the asynchronous computation.
no setterinherited
stream Stream<T>?
The Stream currently being listened to.
getter/setter pair
value AsyncSnapshot<T>
The current value stored in this notifier.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
cancel() → void
Unsubscribes to existing Future or Stream and sets snapshot to 'none'.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
inState(ConnectionState state) AsyncSnapshot<T>
Returns a snapshot like this one, but in the specified state.
inherited
maybeWhen<R>({bool skipLoading = false, R data(T data)?, R error(Object error, StackTrace stackTrace)?, R loading()?, R none()?, required R orElse()}) → R

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Allows you to define custom behavior for different states of an AsyncSnapshot by providing callbacks for data, error, loading, and none.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() String
A string representation of this object.
inherited
when<R>({bool skipLoading = false, required R data(T data), required R error(Object error, StackTrace stackTrace), required R loading(), R none()?}) → R

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Allows you to define custom behavior for different states of an AsyncSnapshot by providing callbacks for data, error, loading, and none.
whenData<R>(R map(T data)) AsyncSnapshot<R>

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Applies map when this snapshot hasData.
whenError(Object map(Object error)) AsyncSnapshot<T>

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Applies map when this snapshot hasError.
whenOrNull<R>({bool skipLoading = false, R data(T data)?, R error(Object error, StackTrace stackTrace)?, R loading()?, R none()?}) → R?

Available on AsyncSnapshot<T>, provided by the AsyncSnapshotExtension extension

Allows you to define custom behavior for different states of an AsyncSnapshot by providing callbacks for data, error, loading, and none.

Operators

operator <<(Listenable other) → T

Available on T, provided by the ChangeNotifierSyncExtension extension

Receives notifications from a Listenable.
operator ==(Object other) bool
The equality operator.
inherited
operator >>(ChangeNotifier other) → T

Available on T, provided by the ListenableSyncExtension extension

Sends notifications to a ChangeNotifier.