http
1.6.0, released a year ago by dart.dev
A composable, Future‑based library for making HTTP requests across platforms.
WASM-readyRock solidQuiet but busy
What it does
Provides high‑level functions and client classes to perform HTTP GET, POST, and other requests. Supports persistent connections, request retry, and aborting on web, mobile, and desktop.
AI-written summary of version 1.6.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Simple REST calls without heavy abstraction
- Need cross‑platform support (mobile, web, desktop)
- Want easy testability with mock clients
Skip it when
- Require built‑in authentication or OAuth flows
- Need GraphQL or gRPC client features
- Prefer code‑generated API clients
Strengths
- Multi‑platform (mobile, web, desktop)
- Simple, Future‑based API
- Easy to mock for testing
- Retry and abort capabilities
Weaknesses
- No built‑in JSON serialization or auth helpers
- Limited to low‑level HTTP, no higher‑level abstractions
- No code generation
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
May require additional Android/iOS network configuration (e.g., cleartext traffic settings).
import 'package:http/http.dart' as http;
void main() async {
var url = Uri.https('example.com', 'path');
var response = await http.get(url);
print('Status: ${response.statusCode}');
print('Body: ${response.body}');
}Alternatives
Packages that do the same job and could replace http.
Works with
Packages commonly used together with http: ones it builds on, ones built on it, and its own family.
- webhttp depends on itLightweight bindings for browser APIs via JS interop
- asynchttp depends on itUtility classes and helpers that extend Dart's async library.
- http_parserhttp depends on itA platform-independent package for parsing and serializing HTTP formats.
- built_valueSame familyImmutable value types with builders, enum classes and JSON serialization for Dart.
- platformSame familyCross‑platform abstraction for querying runtime platform info in Dart.
- testSame familyA full featured library for writing and running Dart tests across platforms.
- matcherSame familySupport for specifying test expectations via an extensible Matcher class.
- intlSame familyA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.