CancellationController class final

The writable side of a cancellation.

A caller creates a controller, passes its token into an operation (e.g. ai.generate(..., cancel: controller.token)), and later calls cancel to request that the operation stop.

This is the Dart analog of the Web AbortController.

Constructors

CancellationController()

Properties

hashCode → int
The hash code for this object.
no setterinherited
isCancelled → bool
Whether cancel has already been called.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
token → CancellationToken
The read-only token to hand to the operation being controlled.
final

Methods

cancel([Object? reason]) → void
Requests cancellation (idempotent). An optional reason is surfaced on CancellationToken.reason and the thrown CancelledException.
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