cancellation_token_http
2.1.0, released 2 years ago by jonathancole.dev
A fork of Dart's HTTP package with request cancellation support using cancellation tokens.
What it does
It wraps Dart's official HTTP package to allow ongoing network requests to be cancelled via a CancellationProvider/CancellationToken. It also supports canceling isolate-based JSON parsing when paired with the cancellation_token package.
AI-written summary of version 2.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to cancel pending HTTP requests in a Dart or Flutter application.
- You want a drop-in fork of the standard http package with cancellation capabilities.
Skip it when
- You are already using Dio or another networking package that natively supports request cancellation.
- You do not need request cancellation functionality.
Strengths
- Maintains the familiar API of Dart's official http package.
- Integrates seamlessly with the cancellation_token package for combined network and isolate parsing cancellation.
Weaknesses
- It is a fork of the standard http package, meaning updates from upstream must be manually merged by the maintainer.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
import 'package:cancellation_token_http/http.dart' as http;
var token = http.CancellationToken();
try {
var response = await http.get(
Uri.parse('https://example.com/foobar.txt'),
cancellationToken: token,
);
} on http.CancelledException {
print('Request cancelled');
}Alternatives
Packages that do the same job and could replace cancellation_token_http.
Works with
Packages commonly used together with cancellation_token_http: ones it builds on, ones built on it, and its own family.
- webcancellation_token_http depends on itLightweight bindings for browser APIs via JS interop
- asynccancellation_token_http depends on itUtility classes and helpers that extend Dart's async library.
- http_parsercancellation_token_http depends on itA platform-independent package for parsing and serializing HTTP formats.
- cancellation_tokencancellation_token_http depends on itEasy async task cancellation for tasks using cancellation tokens in Dart.