http2
3.2.0, released 4 days ago by dart.dev
An HTTP/2 implementation in Dart for low-level transport and pooled HTTP/2 requests.
What it does
Provides an HTTP/2 interface on top of a bidirectional stream of bytes, allowing raw HTTP/2 communication as well as a pooled `http.Client` implementation that multiplexes requests over shared connections.
AI-written summary of version 3.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to make concurrent requests multiplexed over a shared HTTP/2 connection
- You are implementing low-level HTTP/2 clients or servers in Dart
- You need a `package:http` Client backed exclusively by HTTP/2
Skip it when
- You need automatic fallback to HTTP/1.1 for servers that do not support HTTP/2
- You just want a simple high-level REST client without dealing with transport streams
Strengths
- Supports multiplexing multiple requests over a single connection
- Includes `Http2Client` for pooled `package:http` compatibility
- Provides fine-grained control over frames, streams, and transport connections
Weaknesses
- Does not fall back to HTTP/1.1 if a server fails to negotiate HTTP/2
- Requires handling low-level byte streams and header framing for custom requests
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
import 'package:http2/client.dart';
Future<void> main() async {
final client = Http2Client();
final response = await client.get(Uri.parse('https://example.com/'));
print(response.body);
client.close();
}Alternatives
Packages that do the same job and could replace http2.
Works with
Packages commonly used together with http2: ones it builds on, ones built on it, and its own family.
- poolhttp2 depends on itManage a finite pool of resources to control concurrent operations.
- 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.
- asyncSame familyUtility classes and helpers that extend Dart's async library.
- hooksSame familyDart API for the JSON-based protocol for package build and link hooks.
- code_assetsSame familyProvides the hook protocol specification for bundling native code with Dart packages.
- testSame familyA full featured library for writing and running Dart tests across platforms.
- matcherSame familySupport for specifying test expectations via an extensible Matcher class.