CancelToken class

An instance which controls cancellation of Dio's requests, build from Completer.

You can cancel requests by using a CancelToken. One token can be shared with different requests. When cancel is invoked, all requests using this token will be cancelled.

Constructors

CancelToken()

Properties

cancelError DioError?
If request have been canceled, save the cancel error.
no setter
hashCode int
The hash code for this object.
no setterinherited
isCancelled bool
Whether the token is cancelled.
no setter
requestOptions RequestOptions?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
whenCancel Future<DioError>
When cancelled, this future will be resolved.
no setter

Methods

cancel([Object? reason]) → void
Cancel the request with the given reason.
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

Static Methods

isCancel(DioError error) bool
Whether the error is thrown by cancel.