CancelToken class
Token that allows the caller to cancel an in-flight request.
Usage:
final token = CancelToken();
userApi.getUser(id: 1, cancelToken: token);
// ... later:
token.cancel('User navigated away');
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Returns true if cancel has been called.
no setter
- reason → String?
-
The cancellation reason, if provided.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancel(
[String? reason]) → void - Cancels the associated request.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited