CancelableOperation<T> class

An asynchronous operation that can be cancelled.

The value of this operation is exposed as value. When this operation is cancelled, value won't complete either successfully or with an error. If value has already completed, cancelling the operation does nothing.

Constructors

CancelableOperation.fromFuture(Future<T> result, {FutureOr onCancel()?})
Creates a CancelableOperation with the same result as the result future.
factory
CancelableOperation.fromValue(T value)
Creates a CancelableOperation which completes to value.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isCanceled bool
Whether this operation has been canceled before it completed.
no setter
isCompleted bool
Whether the result of this operation is ready.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value Future<T>
The result of this operation, if not cancelled.
no setter

Methods

asStream() Stream<T>
Creates a Stream containing the result of this operation.
cancel() Future
Cancels this operation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
then<R>(FutureOr<R> onValue(T), {FutureOr<R> onError(Object, StackTrace)?, FutureOr<R> onCancel()?, bool propagateCancel = true}) CancelableOperation<R>
Creates a new cancelable operation to be completed when this operation completes normally or as an error, or is cancelled.
thenOperation<R>(FutureOr<void> onValue(T, CancelableCompleter<R>), {FutureOr<void> onError(Object, StackTrace, CancelableCompleter<R>)?, FutureOr<void> onCancel(CancelableCompleter<R>)?, bool propagateCancel = true}) CancelableOperation<R>
Creates a new cancelable operation to be completed when this operation completes normally or as an error, or is cancelled.
toString() String
A string representation of this object.
inherited
valueOrCancellation([T? cancellationValue]) Future<T?>
Creates a Future that completes when this operation completes or when it's cancelled.

Operators

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

Static Methods

fromSubscription(StreamSubscription<void> subscription) CancelableOperation<void>
Creates a CancelableOperation wrapping subscription.
race<T>(Iterable<CancelableOperation<T>> operations) CancelableOperation<T>
Creates a CancelableOperation that completes with the value of the first of operations to complete.