Skip to content
pubscout

cronet_http

1.10.1, released 4 weeks ago by dart.dev

An Android Flutter plugin providing access to the Cronet HTTP client.

Rock solid
$ flutter pub add cronet_http
Source repository

What it does

Provides an Android Flutter plugin that accesses the Cronet HTTP client, supporting features like HTTP/3, configurable caching, and Android HTTP proxies.

AI-written summary of version 1.10.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need advanced Android HTTP features like HTTP/3 or configurable caching.
  • You want to use the package:http Client interface with Cronet on Android.

Skip it when

  • You are targeting platforms other than Android.
  • You prefer the default socket-based dart:io HttpClient.

Strengths

  • Automatically supports Android platform features such as HTTP proxies.
  • Supports configurable caching.
  • Supports more HTTP features such as HTTP/3.

Weaknesses

  • Android-only plugin.
  • Depends on Google Play Services by default unless configured for embedded Cronet.

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
4

Can optionally use embedded Cronet without Google Play Services by setting the dart-define `cronetHttpNoPlay=true`.

import 'package:cronet_http/cronet_http.dart';
import 'package:http/http.dart';
import 'package:http/io_client.dart';

void main() async {
  final Client httpClient;
  if (Platform.isAndroid) {
    final engine = CronetEngine.build(
        cacheMode: CacheMode.memory,
        cacheMaxSize: 2 * 1024 * 1024,
        userAgent: 'Package Client');
    httpClient = CronetClient.fromCronetEngine(engine, closeEngine: true);
  } else {
    httpClient = IOClient(HttpClient()..userAgent = 'Package Client');
  }

  final response = await httpClient.get(
    Uri.https('pub.dev', '/api/packages/cronet_http/score'),
  );
  httpClient.close();
}

Alternatives

Packages that do the same job and could replace cronet_http.

  • dio

    For a powerful HTTP client with interceptors, global configuration, and form data support.

Works with

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