HttpCancelToken class
Cancle token
var http = Http.getInstances(HttpBaseOptions({
name: 'defaultApi',
baseUrl: 'http://domain.com/api/v1',
}));
var cancelToken = HttpCancelToken();
try {
var httpGet = http.get('/users', cancelToken: cancelToken);
Future.delayed(Duration(milliseconds: 100), () {
cancelToken.cancel();
});
await httpGet;
} on HttpError catch (e) {
if (HttpError.type == HttpErrorType.cancel) {
print('Has been canceled!');
}
throw e;
}
Constructors
Properties
- cancelError → DioError?
-
If request have been canceled, save the cancel Error.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
whether cancelled
no setterinherited
- requestOptions ↔ RequestOptions?
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
whenCancel
→ Future<
DioError> -
When cancelled, this future will be resolved.
no setterinherited
Methods
-
cancel(
[dynamic reason]) → void -
Cancel the request
inherited
-
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