CancellableCompleter<T> class

A Completer that can be cancelled using a CancellationToken.

An optional onCancel callback can be provided to clean up resources when the completer is cancelled.

Implemented types
Mixed in types

Constructors

CancellableCompleter(CancellationToken? cancellationToken, {OnCancelCallback? onCancel})
CancellableCompleter.sync(CancellationToken? cancellationToken, {OnCancelCallback? onCancel})
Creates a CancellableCompleter that completes synchronously, similar to Completer.sync().

Properties

future Future<T>
The future that is completed by this completer.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
isCancelled bool
Whether or not the completer was cancelled.
no setter
isCompleted bool
Whether the future has been completed.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

complete([FutureOr<T>? value]) → void
Completes future with the supplied values.
override
completeError(Object error, [StackTrace? stackTrace]) → void
Complete future with an error.
override
maybeAttach(CancellationToken? token) bool
Attaches to the CancellationToken only if it hasn't already been cancelled. If the token has already been cancelled, onCancel is called instead.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCancel(Exception cancelException, [StackTrace? stackTrace]) → void
Called when the attached token is cancelled.
override
toString() String
A string representation of this object.
inherited

Operators

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