[cronet_http] 🏗️ Use dart-define to determine dependency#1111
[cronet_http] 🏗️ Use dart-define to determine dependency#1111brianquinlan merged 15 commits intodart-lang:masterfrom AlexV525:feat/dart-define-embedded
Conversation
|
Require these PRs to land first: |
|
This also includes #1101. |
# Conflicts: # .github/workflows/cronet.yml # pkgs/cronet_http/android/build.gradle # pkgs/cronet_http/example/android/app/build.gradle # pkgs/cronet_http/tool/prepare_for_embedded.dart
brianquinlan
left a comment
There was a problem hiding this comment.
This is a really cool approach! I think that you need to increment the pub spec version and add an entry to the CHANGELOG.
One this is live, I think that I can add a note to cronet_http_embedded and deprecate it.
| userAgent: 'Book Agent'); | ||
| cacheMode: CacheMode.memory, | ||
| cacheMaxSize: 2 * 1024 * 1024, | ||
| userAgent: 'Book Agent', |
There was a problem hiding this comment.
There seems to be some random formatting changes in this file...isn't this formatting actually incorrect?
There was a problem hiding this comment.
Flutter prefers trailing commas, which makes the formatting different.
There was a problem hiding this comment.
This just looks misindented though. Can you change it back?
There was a problem hiding this comment.
Ah, the extra space. Would it be accepted if I only took it away?
|
|
||
| ### Use embedded Cronet | ||
|
|
||
| The embedded [Cronet][] is provided as `org.chromium.net:cronet-embedded` |
There was a problem hiding this comment.
Maybe something more explicit like:
By default, package:cronet_http uses the [Cronet][] library provided by [Google Play Services][].
If you want your application to work without [Google Play Services][], you can instead depend on the org.chromium.net:cronet-embedded package by using dart-define to set cronetHttpNoPlay is set to true.
For example:
...
There was a problem hiding this comment.
By default,
package:cronet_httpuses the [Cronet][] library provided by [Google Play Services][].
The first paragraph duplicates the previous paragraphs. I'll take the second.
| For example: | ||
|
|
||
| ``` | ||
| flutter run --dart-define=cronetHttpNoPlay=true |
There was a problem hiding this comment.
The convention seems to be to use name_with_underscore. So maybe:
cronet_http_no_play=true
There was a problem hiding this comment.
Any guide suggesting this?
There was a problem hiding this comment.
No, I just looked at some existing defines e.g. test_runner.configuration.
But it is not consistent so feel free to leave it this way.
|
After patching this in and using it for a bit, I'm even more amazed by this approach! |
|
@brianquinlan Thanks for the review. I'll update this after #1091 gets merged. |
# Conflicts: # .github/workflows/cronet.yml # pkgs/cronet_http/README.md
| userAgent: 'Book Agent'); | ||
| cacheMode: CacheMode.memory, | ||
| cacheMaxSize: 2 * 1024 * 1024, | ||
| userAgent: 'Book Agent', |
There was a problem hiding this comment.
This just looks misindented though. Can you change it back?
| For example: | ||
|
|
||
| ``` | ||
| flutter run --dart-define=cronetHttpNoPlay=true |
There was a problem hiding this comment.
No, I just looked at some existing defines e.g. test_runner.configuration.
But it is not consistent so feel free to leave it this way.
|
Thanks! |
Revisions updated by `dart tools/rev_sdk_deps.dart`. http (https://github.com/dart-lang/http/compare/ce0de37..6e0a46f): 6e0a46f 2024-02-24 Alex Li [cronet_http] 🏗️ Use dart-define to determine dependency (dart-lang/http#1111) d5cab74 2024-02-23 Alex Li 👷 Update configuration related files (dart-lang/http#1091) 6873731 2024-02-22 Brian Quinlan Make it possible for `CronetClient` to own the lifetime of an existing `CronetEngine` (dart-lang/http#1137) protobuf (https://github.com/dart-lang/protobuf/compare/f085bfd..ef0ab7d): ef0ab7d 2024-02-23 Sebastian Optimize repeated field decoding (google/protobuf.dart#911) tools (https://github.com/dart-lang/tools/compare/9f4e6a4..c7fbf26): c7fbf26 2024-02-21 Elias Yishak Fallback to current datetime when failing on parse session json file (dart-lang/tools#235) web (https://github.com/dart-lang/web/compare/975e55c..d96c01d): d96c01d 2024-02-23 Srujan Gaddam Use extension types and generics internally (dart-lang/web#184) yaml_edit (https://github.com/dart-lang/yaml_edit/compare/82ab64d..54884db): 54884db 2024-02-23 Devon Carew update to the latest sdk; update lints (dart-archive/yaml_edit#68) Change-Id: Ib2cb7971df05f4501f81fe5c04b7eaf88d0d93a3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354381 Commit-Queue: Devon Carew <devoncarew@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Instead of creating a new embedded package, we can use
dart-defineto conditionally implement dependencies.package:cronet_http_embeddedneeds a new name and publisher #1105Contribution guidelines:
dart format.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.