ZenCancelToken class
A token that can be used to signal cancellation to async operations.
Designed to be platform-agnostic. Can be easily adapted to:
- Dio:
cancelToken: token.toDioCancelToken()(via extension) - Http:
token.onCancel(() => client.close())
Constructors
- ZenCancelToken([String? message])
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Whether cancellation has been requested
no setter
- message → String?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancel(
[String? reason]) → void - Request cancellation
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCancel(
void callback()) → void - Register a callback to be invoked when the token is cancelled. If the token is already cancelled, the callback is invoked immediately.
-
throwIfCancelled(
) → void - Throw an exception if the token is cancelled
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited