ZenithCancellationToken class
A one-shot cancellation signal passed to async tasks so they can abort in-flight work (HTTP calls, DB operations) when the owning scope ends.
userScope.runWithToken((token) async {
token.onCancel(() => httpClient.close());
final data = await httpClient.get('/api/data');
if (token.isCancelled) return;
stateNode.value = data;
});
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Whether this token has been cancelled.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancel(
) → void - Cancels this token, invoking all registered onCancel callbacks.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCancel(
void callback()) → void -
Registers
callbackto run synchronously when this token is cancelled. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited