Skip to content
pubscout

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.

$ flutter pub add http2
Source repository

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.

  • dio

    If you want a feature-rich HTTP client with interceptors, global configuration, and form data support.

Works with

Packages commonly used together with http2: ones it builds on, ones built on it, and its own family.