CancelableOperation<T> class Null safety

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.


CancelableOperation.fromFuture(Future<T> result, {FutureOr onCancel()?})
Creates a CancelableOperation with the same result as the result future.


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


asStream() Stream<T>
Creates a Stream containing the result of this operation.
cancel() Future
Cancels this operation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
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.
toString() String
A string representation of this object.
valueOrCancellation([T? cancellationValue]) Future<T?>
Creates a Future that completes when this operation completes or when it's cancelled.


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

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.