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
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.
Works with
Packages commonly used together with cronet_http: ones it builds on, ones built on it, and its own family.
- jnicronet_http depends on itProvides Dart/Flutter bindings to call native Java code via JNI.
- jni_fluttercronet_http depends on itAccess Flutter Android APIs from Dart.
- http_profilecronet_http depends on itAllows custom HTTP client authors to integrate requests with the DevTools Network View.
- http2Same familyAn HTTP/2 implementation in Dart for low-level transport and pooled HTTP/2 requests.
- grpcSame familyDart implementation of gRPC, a high performance universal RPC framework.
- cupertino_httpSame familymacOS/iOS Flutter plugin providing access to the Foundation URL Loading System.
- native_dio_adapterBuilt on cronet_httpA Dio HTTP client adapter that uses native platform HTTP stacks via cupertino_http and cronet_http.