-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make Flutter version information accessible at runtime #140783
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
Conversation
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
AlexV525
left a comment
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.
Early review
| const List<String> dartDefines = [ | ||
| 'FLUTTER_VERSION', | ||
| 'FLUTTER_CHANNEL', | ||
| 'FLUTTER_GIT_URL', |
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.
I'm wondering if this could cause data leaking. This should be in a really low traffic but still possible?
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.
Yeah, I've also wondered that already. I'm not too invested in this data. I just included it to keep the FlutterVersion class on par with the output of flutter --version
packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
Outdated
Show resolved
Hide resolved
| /// | ||
| /// See also: | ||
| /// - [Platform.version](https://api.dart.dev/stable/dart-io/Platform/version.html) | ||
| class FlutterVersion { |
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.
I'm open to better names, maybe something like FlutterMeta?
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { |
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.
I'm not sure about these tests, if you have better ideas I'm all ears.
Problems with testing this is to know the Flutter version at runtime, I need to pass this information either as Dart define to the code or I need to execute the flutter tool via process at runtime, but the tool might not be available in the integration test environment. The latter is not possible in the web environment. The former requires a lot of code to make all the information even available to an integration test, as it's not individually available to query.
Instead, I wrote more extensive tool tests and here I just verify that the properties match their respective Dart defines.
This comment was marked as resolved.
This comment was marked as resolved.
|
I was thinking about how the https://github.com/dart-lang/sdk/blob/01ac55d5f0f2433e643a05575e598a8fa4f2431c/sdk/lib/io/platform_impl.dart#L32 Which means:
|
But only on |
Manual roll Flutter from 39b4951 to 911aa75 (56 revisions) Manual roll requested by [email protected] flutter/flutter@39b4951...911aa75 2025-02-21 [email protected] Remove legacy scenec stuff from flutter_tool (flutter/flutter#163569) 2025-02-21 [email protected] [fuchsia] reorder tests in test_suites.yaml and update the comment (flutter/flutter#163799) 2025-02-21 [email protected] Roll Dart SDK from 7ceb3be8ed0a to c5e582f15b6c (2 revisions) (flutter/flutter#163844) 2025-02-21 [email protected] Roll Packages from a9b9172 to 5a721da (2 revisions) (flutter/flutter#163848) 2025-02-21 [email protected] Roll Dart SDK from ad642ee6f94b to 7ceb3be8ed0a (2 revisions) (flutter/flutter#163832) 2025-02-21 [email protected] Update how to use VSCode with `clangd` after the monorepo merge (flutter/flutter#163671) 2025-02-21 [email protected] Reland #163711 after #163780 (flutter/flutter#163812) 2025-02-21 [email protected] Fix incorrect function name in FlutterEngineRun documentation (flutter/flutter#163696) 2025-02-21 [email protected] Roll Dart SDK from 557cbf2c7da6 to ad642ee6f94b (5 revisions) (flutter/flutter#163794) 2025-02-21 [email protected] [canvaskit] Use `visualViewport.scale` to determine device pixel ratio. (flutter/flutter#163688) 2025-02-21 [email protected] [DisplayList] Migrate rendering tests and benchmarks to DL geometry (flutter/flutter#163766) 2025-02-21 [email protected] Make `releaseMode` explicit, inform `determineDevDependencies` entirely on the flag (flutter/flutter#163780) 2025-02-21 [email protected] Ensure `exclude_dev_dependencies_test` runs if `flutter_tools` changes. (flutter/flutter#163768) 2025-02-21 [email protected] WebKit should respect TextCapitalization.words (flutter/flutter#161027) 2025-02-21 [email protected] CupertinoSliverNavigationBar.search fidelity updates (flutter/flutter#163089) 2025-02-21 [email protected] feat: Add selectionColor property to selectable text (flutter/flutter#162177) 2025-02-20 [email protected] Restore `linux_android_emulator_tests` to CI. (flutter/flutter#163747) 2025-02-20 [email protected] introduce system color palette (flutter/flutter#163335) 2025-02-20 [email protected] [web] DRY up access to headers required for multi-threaded WebAssembly (flutter/flutter#163555) 2025-02-20 [email protected] fix(CupertinoDatePicker): font is inconsistent (flutter/flutter#162932) 2025-02-20 [email protected] Create Android-API-And-Related-Versions.md (flutter/flutter#163556) 2025-02-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Avoid implicitly setting `determineDevDependencies: true` (it's not a safe operation) (#163711)" (flutter/flutter#163762) 2025-02-20 [email protected] Revert "Create g3_bug.yml" (flutter/flutter#163757) 2025-02-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Make Flutter version information accessible at runtime (#140783)" (flutter/flutter#163753) 2025-02-20 [email protected] Skip Xcode install on mac_mokey Android tests (flutter/flutter#163685) 2025-02-20 [email protected] Roll Dart SDK from 2cecb16348e4 to 557cbf2c7da6 (3 revisions) (flutter/flutter#163705) 2025-02-20 [email protected] Add `FlutterVersion.engineCommitDate`, helps signal engine artifact SHA issues (flutter/flutter#163652) 2025-02-20 [email protected] Avoid implicitly setting `determineDevDependencies: true` (it's not a safe operation) (flutter/flutter#163711) 2025-02-20 [email protected] It is now safe to call `getBuildMode().release` (flutter/flutter#163712) 2025-02-20 [email protected] [iOS] remove Skia interfaces from iOS platform code. (flutter/flutter#163505) 2025-02-20 [email protected] Make Flutter version information accessible at runtime (flutter/flutter#140783) 2025-02-20 [email protected] [windows] Implement merged UI and platform thread (flutter/flutter#162935) 2025-02-20 [email protected] `CircularProgressIndicator` throws null exception (flutter/flutter#163356) 2025-02-20 [email protected] Fix the issue where DropdownMenu does not gain focus when tapped. (flutter/flutter#162874) 2025-02-20 [email protected] Check for tracked engine.version before overriding (flutter/flutter#163672) 2025-02-20 [email protected] showDialogs adds a `requestFocus` parameter. (flutter/flutter#162928) 2025-02-20 [email protected] Create helper method to dispatch object creation and disposal. (flutter/flutter#163637) 2025-02-20 [email protected] Redistribute iOS TESTOWNERS (flutter/flutter#163653) 2025-02-20 [email protected] enclosingElement -> enclosingElement3 (flutter/flutter#163681) 2025-02-19 [email protected] [ Widget Preview ] Move `preview_detector_test.dart` from `general.shard` to `commands.shard` (flutter/flutter#163619) 2025-02-19 [email protected] [iOS] always post new task during gesture dispatch. (flutter/flutter#163646) 2025-02-19 [email protected] Allow flutter tools to detach a running Chrome session (flutter/flutter#163349) 2025-02-19 [email protected] Reland "[Impeller] add support for rational bezier conics to Path (#63282)" (flutter/flutter#163645) 2025-02-19 [email protected] [web:a11y] wheel events switch to pointer mode (flutter/flutter#163582) ...
…)" (#163761) Reverts #163753 Relands #140783 Original PR description below ------ This makes various Flutter version information available at runtime. It's basically the same as executing `flutter --version`. This is especially useful for tools like Crashlytics or Sentry (see for example getsentry/sentry-dart#416). Usage example: ```dart FlutterVersion.version; // 3.16.5 FlutterVersion.channel; // stable FlutterVersion.gitUrl; // https://github.com/flutter/flutter.git FlutterVersion.frameworkRevision; // 78666c8 FlutterVersion.engineRevision; // 3f3e560236 FlutterVersion.dartVersion; // 3.2.3 ``` This approach has prior art as seen in #134179. Fixes #61814 <!-- *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* --> ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
) Manual roll Flutter from 39b4951 to 911aa75 (56 revisions) Manual roll requested by [email protected] flutter/flutter@39b4951...911aa75 2025-02-21 [email protected] Remove legacy scenec stuff from flutter_tool (flutter/flutter#163569) 2025-02-21 [email protected] [fuchsia] reorder tests in test_suites.yaml and update the comment (flutter/flutter#163799) 2025-02-21 [email protected] Roll Dart SDK from 7ceb3be8ed0a to c5e582f15b6c (2 revisions) (flutter/flutter#163844) 2025-02-21 [email protected] Roll Packages from a9b9172 to 5a721da (2 revisions) (flutter/flutter#163848) 2025-02-21 [email protected] Roll Dart SDK from ad642ee6f94b to 7ceb3be8ed0a (2 revisions) (flutter/flutter#163832) 2025-02-21 [email protected] Update how to use VSCode with `clangd` after the monorepo merge (flutter/flutter#163671) 2025-02-21 [email protected] Reland #163711 after #163780 (flutter/flutter#163812) 2025-02-21 [email protected] Fix incorrect function name in FlutterEngineRun documentation (flutter/flutter#163696) 2025-02-21 [email protected] Roll Dart SDK from 557cbf2c7da6 to ad642ee6f94b (5 revisions) (flutter/flutter#163794) 2025-02-21 [email protected] [canvaskit] Use `visualViewport.scale` to determine device pixel ratio. (flutter/flutter#163688) 2025-02-21 [email protected] [DisplayList] Migrate rendering tests and benchmarks to DL geometry (flutter/flutter#163766) 2025-02-21 [email protected] Make `releaseMode` explicit, inform `determineDevDependencies` entirely on the flag (flutter/flutter#163780) 2025-02-21 [email protected] Ensure `exclude_dev_dependencies_test` runs if `flutter_tools` changes. (flutter/flutter#163768) 2025-02-21 [email protected] WebKit should respect TextCapitalization.words (flutter/flutter#161027) 2025-02-21 [email protected] CupertinoSliverNavigationBar.search fidelity updates (flutter/flutter#163089) 2025-02-21 [email protected] feat: Add selectionColor property to selectable text (flutter/flutter#162177) 2025-02-20 [email protected] Restore `linux_android_emulator_tests` to CI. (flutter/flutter#163747) 2025-02-20 [email protected] introduce system color palette (flutter/flutter#163335) 2025-02-20 [email protected] [web] DRY up access to headers required for multi-threaded WebAssembly (flutter/flutter#163555) 2025-02-20 [email protected] fix(CupertinoDatePicker): font is inconsistent (flutter/flutter#162932) 2025-02-20 [email protected] Create Android-API-And-Related-Versions.md (flutter/flutter#163556) 2025-02-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Avoid implicitly setting `determineDevDependencies: true` (it's not a safe operation) (#163711)" (flutter/flutter#163762) 2025-02-20 [email protected] Revert "Create g3_bug.yml" (flutter/flutter#163757) 2025-02-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Make Flutter version information accessible at runtime (#140783)" (flutter/flutter#163753) 2025-02-20 [email protected] Skip Xcode install on mac_mokey Android tests (flutter/flutter#163685) 2025-02-20 [email protected] Roll Dart SDK from 2cecb16348e4 to 557cbf2c7da6 (3 revisions) (flutter/flutter#163705) 2025-02-20 [email protected] Add `FlutterVersion.engineCommitDate`, helps signal engine artifact SHA issues (flutter/flutter#163652) 2025-02-20 [email protected] Avoid implicitly setting `determineDevDependencies: true` (it's not a safe operation) (flutter/flutter#163711) 2025-02-20 [email protected] It is now safe to call `getBuildMode().release` (flutter/flutter#163712) 2025-02-20 [email protected] [iOS] remove Skia interfaces from iOS platform code. (flutter/flutter#163505) 2025-02-20 [email protected] Make Flutter version information accessible at runtime (flutter/flutter#140783) 2025-02-20 [email protected] [windows] Implement merged UI and platform thread (flutter/flutter#162935) 2025-02-20 [email protected] `CircularProgressIndicator` throws null exception (flutter/flutter#163356) 2025-02-20 [email protected] Fix the issue where DropdownMenu does not gain focus when tapped. (flutter/flutter#162874) 2025-02-20 [email protected] Check for tracked engine.version before overriding (flutter/flutter#163672) 2025-02-20 [email protected] showDialogs adds a `requestFocus` parameter. (flutter/flutter#162928) 2025-02-20 [email protected] Create helper method to dispatch object creation and disposal. (flutter/flutter#163637) 2025-02-20 [email protected] Redistribute iOS TESTOWNERS (flutter/flutter#163653) 2025-02-20 [email protected] enclosingElement -> enclosingElement3 (flutter/flutter#163681) 2025-02-19 [email protected] [ Widget Preview ] Move `preview_detector_test.dart` from `general.shard` to `commands.shard` (flutter/flutter#163619) 2025-02-19 [email protected] [iOS] always post new task during gesture dispatch. (flutter/flutter#163646) 2025-02-19 [email protected] Allow flutter tools to detach a running Chrome session (flutter/flutter#163349) 2025-02-19 [email protected] Reland "[Impeller] add support for rational bezier conics to Path (#63282)" (flutter/flutter#163645) 2025-02-19 [email protected] [web:a11y] wheel events switch to pointer mode (flutter/flutter#163582) ...
) Manual roll Flutter from 39b4951 to 911aa75 (56 revisions) Manual roll requested by [email protected] flutter/flutter@39b4951...911aa75 2025-02-21 [email protected] Remove legacy scenec stuff from flutter_tool (flutter/flutter#163569) 2025-02-21 [email protected] [fuchsia] reorder tests in test_suites.yaml and update the comment (flutter/flutter#163799) 2025-02-21 [email protected] Roll Dart SDK from 7ceb3be8ed0a to c5e582f15b6c (2 revisions) (flutter/flutter#163844) 2025-02-21 [email protected] Roll Packages from a9b9172 to 5a721da (2 revisions) (flutter/flutter#163848) 2025-02-21 [email protected] Roll Dart SDK from ad642ee6f94b to 7ceb3be8ed0a (2 revisions) (flutter/flutter#163832) 2025-02-21 [email protected] Update how to use VSCode with `clangd` after the monorepo merge (flutter/flutter#163671) 2025-02-21 [email protected] Reland #163711 after #163780 (flutter/flutter#163812) 2025-02-21 [email protected] Fix incorrect function name in FlutterEngineRun documentation (flutter/flutter#163696) 2025-02-21 [email protected] Roll Dart SDK from 557cbf2c7da6 to ad642ee6f94b (5 revisions) (flutter/flutter#163794) 2025-02-21 [email protected] [canvaskit] Use `visualViewport.scale` to determine device pixel ratio. (flutter/flutter#163688) 2025-02-21 [email protected] [DisplayList] Migrate rendering tests and benchmarks to DL geometry (flutter/flutter#163766) 2025-02-21 [email protected] Make `releaseMode` explicit, inform `determineDevDependencies` entirely on the flag (flutter/flutter#163780) 2025-02-21 [email protected] Ensure `exclude_dev_dependencies_test` runs if `flutter_tools` changes. (flutter/flutter#163768) 2025-02-21 [email protected] WebKit should respect TextCapitalization.words (flutter/flutter#161027) 2025-02-21 [email protected] CupertinoSliverNavigationBar.search fidelity updates (flutter/flutter#163089) 2025-02-21 [email protected] feat: Add selectionColor property to selectable text (flutter/flutter#162177) 2025-02-20 [email protected] Restore `linux_android_emulator_tests` to CI. (flutter/flutter#163747) 2025-02-20 [email protected] introduce system color palette (flutter/flutter#163335) 2025-02-20 [email protected] [web] DRY up access to headers required for multi-threaded WebAssembly (flutter/flutter#163555) 2025-02-20 [email protected] fix(CupertinoDatePicker): font is inconsistent (flutter/flutter#162932) 2025-02-20 [email protected] Create Android-API-And-Related-Versions.md (flutter/flutter#163556) 2025-02-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Avoid implicitly setting `determineDevDependencies: true` (it's not a safe operation) (#163711)" (flutter/flutter#163762) 2025-02-20 [email protected] Revert "Create g3_bug.yml" (flutter/flutter#163757) 2025-02-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Make Flutter version information accessible at runtime (#140783)" (flutter/flutter#163753) 2025-02-20 [email protected] Skip Xcode install on mac_mokey Android tests (flutter/flutter#163685) 2025-02-20 [email protected] Roll Dart SDK from 2cecb16348e4 to 557cbf2c7da6 (3 revisions) (flutter/flutter#163705) 2025-02-20 [email protected] Add `FlutterVersion.engineCommitDate`, helps signal engine artifact SHA issues (flutter/flutter#163652) 2025-02-20 [email protected] Avoid implicitly setting `determineDevDependencies: true` (it's not a safe operation) (flutter/flutter#163711) 2025-02-20 [email protected] It is now safe to call `getBuildMode().release` (flutter/flutter#163712) 2025-02-20 [email protected] [iOS] remove Skia interfaces from iOS platform code. (flutter/flutter#163505) 2025-02-20 [email protected] Make Flutter version information accessible at runtime (flutter/flutter#140783) 2025-02-20 [email protected] [windows] Implement merged UI and platform thread (flutter/flutter#162935) 2025-02-20 [email protected] `CircularProgressIndicator` throws null exception (flutter/flutter#163356) 2025-02-20 [email protected] Fix the issue where DropdownMenu does not gain focus when tapped. (flutter/flutter#162874) 2025-02-20 [email protected] Check for tracked engine.version before overriding (flutter/flutter#163672) 2025-02-20 [email protected] showDialogs adds a `requestFocus` parameter. (flutter/flutter#162928) 2025-02-20 [email protected] Create helper method to dispatch object creation and disposal. (flutter/flutter#163637) 2025-02-20 [email protected] Redistribute iOS TESTOWNERS (flutter/flutter#163653) 2025-02-20 [email protected] enclosingElement -> enclosingElement3 (flutter/flutter#163681) 2025-02-19 [email protected] [ Widget Preview ] Move `preview_detector_test.dart` from `general.shard` to `commands.shard` (flutter/flutter#163619) 2025-02-19 [email protected] [iOS] always post new task during gesture dispatch. (flutter/flutter#163646) 2025-02-19 [email protected] Allow flutter tools to detach a running Chrome session (flutter/flutter#163349) 2025-02-19 [email protected] Reland "[Impeller] add support for rational bezier conics to Path (#63282)" (flutter/flutter#163645) 2025-02-19 [email protected] [web:a11y] wheel events switch to pointer mode (flutter/flutter#163582) ...
This makes various Flutter version information available at runtime. It's basically the same as executing
flutter --version. This is especially useful for tools like Crashlytics or Sentry (see for example getsentry/sentry-dart#416).Usage example:
This approach has prior art as seen in #134179.
Fixes #61814
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.