Skip to content

Commit 15ec3ba

Browse files
authored
Prepare to publish package:cronet_http as 1.0.0 (#1087)
1 parent 26e55c3 commit 15ec3ba

File tree

3 files changed

+60
-26
lines changed

3 files changed

+60
-26
lines changed

pkgs/cronet_http/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.0
2+
3+
* No functional changes.
4+
15
## 0.4.2
26

37
* Require `package:jni >= 0.7.2` to remove a potential buffer overflow.

pkgs/cronet_http/README.md

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,61 @@
1+
[![pub package](https://img.shields.io/pub/v/cronet_http.svg)](https://pub.dev/packages/cronet_http)
2+
[![package publisher](https://img.shields.io/pub/publisher/cronet_http.svg)](https://pub.dev/packages/cronet_http/publisher)
3+
14
An Android Flutter plugin that provides access to the
2-
[Cronet](https://developer.android.com/guide/topics/connectivity/cronet/reference/org/chromium/net/package-summary)
5+
[Cronet][]
36
HTTP client.
47

58
Cronet is available as part of
6-
[Google Play Services](https://developers.google.com/android/guides/overview).
9+
[Google Play Services][].
710

8-
This package depends on
9-
[Google Play Services](https://developers.google.com/android/guides/overview)
10-
for its Cronet implementation.
11+
This package depends on [Google Play Services][] for its [Cronet][]
12+
implementation.
1113
[`package:cronet_http_embedded`](https://pub.dev/packages/cronet_http_embedded)
12-
is functionally identical to this package but embeds Cronet directly instead
13-
of relying on
14-
[Google Play Services](https://developers.google.com/android/guides/overview).
15-
16-
## Status: Experimental
17-
18-
**NOTE**: This package is currently experimental and published under the
19-
[labs.dart.dev](https://dart.dev/dart-team-packages) pub publisher in order to
20-
solicit feedback.
21-
22-
For packages in the labs.dart.dev publisher we generally plan to either graduate
23-
the package into a supported publisher (dart.dev, tools.dart.dev) after a period
24-
of feedback and iteration, or discontinue the package. These packages have a
25-
much higher expected rate of API and breaking changes.
26-
27-
Your feedback is valuable and will help us evolve this package.
28-
For general feedback and suggestions please comment in the
29-
[feedback issue](https://github.com/dart-lang/http/issues/764).
30-
For bugs, please file an issue in the
31-
[bug tracker](https://github.com/dart-lang/http/issues).
14+
is functionally identical to this package but embeds [Cronet][] directly
15+
instead of relying on [Google Play Services][].
16+
17+
## Motivation
18+
19+
Using [Cronet][], rather than the socket-based [dart:io HttpClient][]
20+
implemententation, has several advantages:
21+
22+
1. It automatically supports Android platform features such as HTTP proxies.
23+
2. It supports configurable caching.
24+
3. It supports more HTTP features such as HTTP/3.
25+
26+
## Using
27+
28+
The easiest way to use this library is via the the high-level interface
29+
defined by [package:http Client][].
30+
31+
This approach allows the same HTTP code to be used on all platforms, while
32+
still allowing platform-specific setup.
33+
34+
```dart
35+
import 'package:cronet_http/cronet_http.dart';
36+
import 'package:http/http.dart';
37+
import 'package:http/io_client.dart';
38+
39+
void main() async {
40+
late Client httpClient;
41+
if (Platform.isAndroid) {
42+
final engine = CronetEngine.build(
43+
cacheMode: CacheMode.memory,
44+
cacheMaxSize: 2 * 1024 * 1024,
45+
userAgent: 'Book Agent');
46+
httpClient = CronetClient.fromCronetEngine(engine);
47+
} else {
48+
httpClient = IOClient(HttpClient()..userAgent = 'Book Agent');
49+
}
50+
51+
final response = await client.get(Uri.https(
52+
'www.googleapis.com',
53+
'/books/v1/volumes',
54+
{'q': 'HTTP', 'maxResults': '40', 'printType': 'books'}));
55+
}
56+
```
57+
58+
[Cronet]: https://developer.android.com/guide/topics/connectivity/cronet/reference/org/chromium/net/package-summary
59+
[dart:io HttpClient]: https://api.dart.dev/stable/dart-io/HttpClient-class.html
60+
[Google Play Services]: https://developers.google.com/android/guides/overview
61+
[package:http Client]: https://pub.dev/documentation/http/latest/http/Client-class.html

pkgs/cronet_http/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cronet_http
2-
version: 0.4.2
2+
version: 1.0.0
33
description: >-
44
An Android Flutter plugin that provides access to the Cronet HTTP client.
55
repository: https://github.com/dart-lang/http/tree/master/pkgs/cronet_http

0 commit comments

Comments
 (0)