setFutureValue method
Future<void>
setFutureValue(
- WhenFuture<
T> whenFuture, - FutureSnapshotListenerCallback<
T> ? listener, - VoidCallback? onFinally
Sets a value after an asynchronous computation that returned a future
Implementation
@protected
Future<void> setFutureValue(
WhenFuture<T> whenFuture,
FutureSnapshotListenerCallback<T>? listener,
VoidCallback? onFinally,
) {
final Object callbackIdentity = Object();
_activeCallbackIdentity = callbackIdentity;
return whenFuture.refreshSnapshots(
(snapshot) {
if (_activeCallbackIdentity != callbackIdentity) return;
listener?.call(snapshot as FutureSnapshot<T>);
_updateSnapshot(snapshot as FutureSnapshot<T>);
},
() {
if (_activeCallbackIdentity != callbackIdentity) return;
onFinally?.call();
},
);
}