-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cronet_http] 🏗️ Use dart-define to determine dependency #1111
[cronet_http] 🏗️ Use dart-define to determine dependency #1111
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
pkgs/cronet_http/README.md
Outdated
userAgent: 'Book Agent'); | ||
cacheMode: CacheMode.memory, | ||
cacheMaxSize: 2 * 1024 * 1024, | ||
userAgent: 'Book Agent', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some random formatting changes in this file...isn't this formatting actually incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flutter prefers trailing commas, which makes the formatting different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just looks misindented though. Can you change it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the extra space. Would it be accepted if I only took it away?
pkgs/cronet_http/README.md
Outdated
} | ||
``` | ||
|
||
### Use embedded Cronet | ||
|
||
The embedded [Cronet][] is provided as `org.chromium.net:cronet-embedded` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default,
package:cronet_http
uses 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention seems to be to use name_with_underscore. So maybe:
cronet_http_no_play=true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any guide suggesting this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
pkgs/cronet_http/README.md
Outdated
userAgent: 'Book Agent'); | ||
cacheMode: CacheMode.memory, | ||
cacheMaxSize: 2 * 1024 * 1024, | ||
userAgent: 'Book Agent', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-lang/yaml_edit#68) Change-Id: Ib2cb7971df05f4501f81fe5c04b7eaf88d0d93a3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354381 Commit-Queue: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
Instead of creating a new embedded package, we can use
dart-define
to conditionally implement dependencies.package:cronet_http_embedded
needs 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.