CancellationToken class
A token that can be used to cancel an in-flight GraphQL operation.
Create a CancellationToken and pass it to operations like GraphQLClient.query or GraphQLClient.mutate to enable cancellation of those operations.
{@tool snippet} Basic usage
final cancellationToken = CancellationToken();
// Start a query
final resultFuture = client.query(
QueryOptions(
document: gql('query { ... }'),
cancellationToken: cancellationToken,
),
);
// Later, cancel the operation
cancellationToken.cancel();
// The resultFuture will complete with a QueryResult containing
// a CancelledException
{@end-tool}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Whether this token has been cancelled.
no setter
-
onCancel
→ Stream<
void> -
A stream that emits when cancellation is requested.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancel(
) → void - Cancel the operation associated with this token.
-
dispose(
) → void - Dispose of this token's resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited