Repository navigation
[flutter_tools] Migrate AndroidSdk and AndroidStudio away from globals - #193650
Conversation
Injects Config, FileSystem, FileSystemUtils, Logger, OperatingSystemUtils, Platform, PlistParser, and ProcessManager explicitly into AndroidSdk and AndroidStudio instead of reading ambient globals.
There was a problem hiding this comment.
Code Review
This pull request refactors AndroidSdk and AndroidStudio to support dependency injection, removing reliance on global variables and allowing tests to be migrated from testUsingContext to testWithoutContext. The review feedback suggests refactoring the constructors of AndroidSdk and AndroidStudio into factory constructors to avoid redundant instantiations of default dependencies when they are not provided. Additionally, it is recommended to resolve PlistParser once in AndroidStudio._allMacOS and pass it to fromMacOSBundle to prevent multiple instantiations inside the loop.
|
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. |
…dk and AndroidStudio Uses factory constructors on AndroidSdk and AndroidStudio so default dependencies are resolved once per instantiation, and resolves PlistParser once in AndroidStudio._allMacOS.
…Studio Allows callers to pass ToolContext rather than individual ToolContext dependencies to AndroidSdk and AndroidStudio constructors and factory methods.
There was a problem hiding this comment.
Code Review
This pull request refactors AndroidSdk and AndroidStudio to use dependency injection via ToolContext instead of relying on legacy globals, and updates associated tests to use fake contexts. The review feedback suggests making fileSystem a required parameter in SDK validation methods to ensure hermeticity, and recommends simplifying several list constructions by removing redundant spread operators and using more idiomatic cascade sorting.
…builder_test.dart`
…and-studio # Conflicts: # packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
|
autosubmit label was removed for flutter/flutter/193650, because Pull request flutter/flutter/193650 is not in a mergeable state. |
flutter/flutter@426be96...5c7e45a 2026-10-15 [email protected] [web_paragraph] Honor TextHeightBehavior.leadingDistribution and default to proportional (flutter/flutter#193736) 2026-10-15 [email protected] Roll Skia from 79a00d7c4898 to d131b7789482 (2 revisions) (flutter/flutter#194446) 2026-10-15 [email protected] Roll Dart SDK from b8ffa9233096 to 84686ea04815 (1 revision) (flutter/flutter#194442) 2026-10-15 [email protected] Roll Dart SDK from e81af2dac9d1 to b8ffa9233096 (1 revision) (flutter/flutter#194432) 2026-10-15 [email protected] Roll Skia from ef24b8f87a2a to 79a00d7c4898 (4 revisions) (flutter/flutter#194431) 2026-10-15 [email protected] Roll Skia from 48c51004ee4e to ef24b8f87a2a (1 revision) (flutter/flutter#194427) 2026-10-15 [email protected] Roll Dart SDK from 6b50116630d0 to e81af2dac9d1 (5 revisions) (flutter/flutter#194422) 2026-10-15 [email protected] Roll Skia from b1be97266d3a to 48c51004ee4e (10 revisions) (flutter/flutter#194421) 2026-10-15 [email protected] RawAutocomplete: Fix focusNode listener mismatch in didUpdateWidget/dispose (flutter/flutter#190686) 2026-10-14 [email protected] [flutter_tools] Wait for iOS simulator log stream before launch (flutter/flutter#193142) 2026-10-14 [email protected] Move Material/Cupertino PRs from design triage to framework triage (flutter/flutter#194244) 2026-10-14 [email protected] refactor(flutter_tools): share FlutterCommand options and OptionBundles (flutter/flutter#194356) 2026-10-14 [email protected] Roll pub packages (flutter/flutter#194413) 2026-10-14 [email protected] Add ContextMenuButtonKind (flutter/flutter#193528) 2026-10-14 [email protected] Split SwiftPM plugin into multiple products (flutter/flutter#193521) 2026-10-14 [email protected] Roll Skia from 43d707a3be0e to b1be97266d3a (8 revisions) (flutter/flutter#194392) 2026-10-14 [email protected] Roll pub packages (flutter/flutter#194398) 2026-10-14 [email protected] [flutter_tools] Migrate AndroidSdk and AndroidStudio away from globals (flutter/flutter#193650) 2026-10-14 [email protected] [flutter_tools] Reload widget-preview when data assets change (flutter/flutter#193437) 2026-10-14 [email protected] [flutter tool] suppress sub-tool analytics during first run (flutter/flutter#194320) 2026-10-14 [email protected] Roll Skia from acde3755d2e2 to 43d707a3be0e (1 revision) (flutter/flutter#194385) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter#193650) Migrates AndroidSdk and AndroidStudio away from globals.dart to explicit dependency injection via ToolContext. Part of flutter#188471 ## 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.
Migrates AndroidSdk and AndroidStudio away from globals.dart to explicit dependency injection via ToolContext.
Part of #188471
Pre-launch Checklist
///).