Google Summer of Code / 2021
cronet.dart
Chromium networking.
A Dart interface.
A proof of concept for an HTTP client for Dart and Flutter built on Chromium’s networking stack. I developed it during Google Summer of Code 2021, mentored by Google’s Dart and Chromium teams.
- Context
- Google Summer of Code 2021
- Stack
- Dart, C, C++, dart:ffi
- Platforms
- Android, Linux, Windows, macOS
- Status
- Proof of concept · succeeded by cronet_http
01 / The idea
A native network stack, without leaving Dart.
Cronet is Chromium’s networking library. This project made its native C API accessible from Dart through dart:ffi, with an interface shaped like dart:io’s HttpClient.
The goal was to let Dart and Flutter applications use the networking stack underneath Chromium while keeping request and response handling familiar.
02 / Under the hood
Across the native boundary.
03 / The interface
Familiar at the call site.
A request to the first website ever made, sent through Chromium’s network stack.
import 'dart:convert';
import 'package:cronet/cronet.dart';
final client = HttpClient();
final request = await client.getUrl(
Uri.parse('http://info.cern.ch/'),
);
final response = await request.close();
response.transform(utf8.decoder).listen(print);
cronet package.04 / Outcome & context
From GSoC to an open-source package.
The project was published under Google’s GitHub organisation and on pub.dev. In the project’s highly parallel workloads, it ran up to twice as fast as dart:io; that result is specific to those workloads.
Following my GSoC proof of concept, Google built the official successor, cronet_http. This page documents my original 2021 work; the successor package is the place to start for current use.