Repository navigation
[tool] Migrate RunCommand to modular dependency injection - #190791
Conversation
ca643e3 to
e883d45
Compare
547fb43 to
9d523b9
Compare
# Conflicts: # packages/flutter_tools/lib/src/commands/run.dart
# Conflicts: # packages/flutter_tools/lib/src/resident_runner.dart
…nner-and-run # Conflicts: # packages/flutter_tools/lib/executable.dart # packages/flutter_tools/lib/src/commands/run.dart
There was a problem hiding this comment.
Code Review
This pull request refactors the Flutter tools codebase by replacing references to global variables with explicitly injected dependencies (such as BuildSystem, BuildTargets, ToolContext, Xcode, and Analytics) across various commands and runners, including AttachCommand, DaemonCommand, RunCommand, ResidentWebRunner, and ResidentRunner. Numerous tests have been updated to accommodate these constructor changes. The review feedback points out several newly introduced public fields on ResidentRunner, DaemonServer, RunCommandBase, and RunCommand that lack documentation, which violates the style guide requirement that all public members must be documented.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/flutter_tools/lib/src/resident_runner.dart (1020-1024)
According to the Flutter style guide, all public members should have documentation. Please add doc comments for the newly added public fields toolContext, analytics, buildTargets, and buildSystem.
/// The injected tool context.
final ToolContext toolContext;
/// The analytics instance used to record usage.
final Analytics analytics;
/// The build targets factory.
final BuildTargets buildTargets;
/// The build system used to compile the application.
final BuildSystem buildSystem;
References
- All public members should have documentation. (link)
packages/flutter_tools/lib/src/commands/daemon.dart (181-184)
According to the Flutter style guide, all public members should have documentation. Please add doc comments for the newly added public fields buildSystem, buildTargets, toolContext, and xcode on DaemonServer.
/// The build system used to compile the application.
final BuildSystem buildSystem;
/// The build targets factory.
final BuildTargets buildTargets;
/// The injected tool context.
final ToolContext toolContext;
/// The Xcode installation, or null on platforms without Xcode support.
final Xcode? xcode;
References
- All public members should have documentation. (link)
packages/flutter_tools/lib/src/commands/run.dart (111-112)
According to the Flutter style guide, all public members should have documentation. Please add doc comments for the newly added public fields buildSystem and buildTargets on RunCommandBase.
/// The build system used to compile the application.
final BuildSystem buildSystem;
/// The build targets factory.
final BuildTargets buildTargets;
References
- All public members should have documentation. (link)
packages/flutter_tools/lib/src/commands/run.dart (433-434)
According to the Flutter style guide, all public members should have documentation. Please add doc comments for the newly added public fields appleContext and deviceManager on RunCommand.
/// The Apple context containing Apple-specific tools and utilities.
final AppleContext appleContext;
/// The device manager used to discover and manage devices.
final DeviceManager? deviceManager;
References
- All public members should have documentation. (link)
…teMachineDaemon args
…nner-and-run # Conflicts: # packages/flutter_tools/lib/src/context/tool_dependencies.dart
…er-and-run # Conflicts: # packages/flutter_tools/lib/src/commands/drive.dart
Remove the `_createToolContext()` helper, which probed `globals.*` inside `try`/`on Object` blocks and copied the results into a `FakeToolContext`, and pass `const DelegatingToolContext()` to the commands under test instead.
Roll Flutter from 4249ccbc18a3 to 426be968b5eb (44 revisions) flutter/flutter@4249ccb...426be96 2026-10-14 [email protected] Allow color delta tolerance in in-memory fuzzy image comparator (flutter/flutter#193937) 2026-10-14 [email protected] [web] Drop stale composing range after text is replaced mid-composition (flutter/flutter#194096) 2026-10-14 [email protected] Roll Skia from 2a2bbea66844 to acde3755d2e2 (1 revision) (flutter/flutter#194376) 2026-10-14 [email protected] Roll Skia from 128c983b12de to 2a2bbea66844 (1 revision) (flutter/flutter#194371) 2026-10-14 [email protected] Roll Skia from 48a294ed4955 to 128c983b12de (3 revisions) (flutter/flutter#194353) 2026-10-14 [email protected] feat(flutter_tools): extract WebDebugConfig from DebuggingOptions (flutter/flutter#194312) 2026-10-14 [email protected] Roll Skia from ea6781c5b6d1 to 48a294ed4955 (2 revisions) (flutter/flutter#194349) 2026-10-14 [email protected] Include <vector> in Android proc_table.h. (flutter/flutter#194325) 2026-10-14 [email protected] Roll Dart SDK from 5933cb486b4a to 6b50116630d0 (28 revisions) (flutter/flutter#194341) 2026-10-14 [email protected] Move GLES3 instancing API entry points to FOR_EACH_IMPELLER_GLES3_PROC (flutter/flutter#194319) 2026-10-14 [email protected] feat(flutter_tools): extract AndroidGradleConfig and move toGradleConfig to AndroidBuildInfo (flutter/flutter#194016) 2026-10-14 [email protected] Roll Skia from ae297bec6012 to ea6781c5b6d1 (8 revisions) (flutter/flutter#194331) 2026-10-14 [email protected] [flutter_tools] Migrate gradle_errors and deferred_components_prebuild_validator away from globals (flutter/flutter#193649) 2026-10-14 [email protected] [Impeller] Cache GLES sampler configuration in RenderPassStateCache (flutter/flutter#193922) 2026-10-14 [email protected] Roll pub packages (flutter/flutter#194332) 2026-10-13 [email protected] [tool] Migrate RunCommand to modular dependency injection (flutter/flutter#190791) 2026-10-13 [email protected] Include `engine/src/flutter/.ci.yaml` in quarterly `goldctl` checklist (flutter/flutter#194316) 2026-10-13 [email protected] [flutter_tools] Remove the last AMD module system support (flutter/flutter#193607) 2026-10-13 [email protected] Roll Skia from 8b3394a60654 to ae297bec6012 (5 revisions) (flutter/flutter#194310) 2026-10-13 [email protected] [web] Remove the a11y placeholder only after the gesture ends (flutter/flutter#194109) 2026-10-13 [email protected] Upgrade goldctl to the latest version (flutter/flutter#193932) 2026-10-13 [email protected] [flutter_tools] Lazily initialize AndroidStudio validation and optimize candidate selection (flutter/flutter#191968) 2026-10-13 [email protected] [flutter_tools] Clean up outdated widget preview TODOs and refactor static state (flutter/flutter#189437) 2026-10-13 [email protected] Roll Skia from e5b5db6d0d6f to 8b3394a60654 (2 revisions) (flutter/flutter#194306) 2026-10-13 [email protected] Redistribute TESTOWNERS for Android team (flutter/flutter#193861) 2026-10-13 [email protected] feat(flutter_tools): introduce Test and Drive specification objects (flutter/flutter#194017) 2026-10-13 [email protected] [Impeller] Keep the aspect ratio when shrinking images to the max texture size (flutter/flutter#194010) 2026-10-13 [email protected] [flutter tool] preserve inherited `DASH__SUPPRESS_ANALYTICS=true` for sub-tools (flutter/flutter#194261) 2026-10-13 [email protected] Roll Packages from d8d9e97 to a1ed23c (9 revisions) (flutter/flutter#194302) 2026-10-13 [email protected] Use PE/COFF AOT snapshots for Windows x64 (flutter/flutter#187594) 2026-10-13 [email protected] Fix Expansible crash when PageStorage holds a non-bool value (flutter/flutter#192195) 2026-10-13 [email protected] Roll Skia from ffeccb3ca58a to e5b5db6d0d6f (1 revision) (flutter/flutter#194297) 2026-10-13 [email protected] Explain why initState() is too early to depend on an inherited widget (flutter/flutter#192727) 2026-10-13 [email protected] Refactor TestPlatformDispatcher (flutter/flutter#192747) 2026-10-13 [email protected] Roll Skia from 3de0984208ec to ffeccb3ca58a (2 revisions) (flutter/flutter#194291) 2026-10-13 [email protected] Roll Skia from 0580c2b780f6 to 3de0984208ec (2 revisions) (flutter/flutter#194281) 2026-10-13 [email protected] Roll Skia from f641d55e07a8 to 0580c2b780f6 (3 revisions) (flutter/flutter#194275) 2026-10-13 [email protected] Roll Skia from 0e5d8d1be81b to f641d55e07a8 (1 revision) (flutter/flutter#194266) 2026-10-13 [email protected] Scaffold view metrics overrides (flutter/flutter#192764) 2026-10-13 [email protected] [web] Add SemanticsRole.listBox and SemanticsRole.option (flutter/flutter#192971) 2026-10-13 [email protected] Pin mac_unopt to macOS 15 (flutter/flutter#194254) 2026-10-13 [email protected] Roll pub packages (flutter/flutter#194257) 2026-10-12 [email protected] Roll Skia from 17f6986c226c to 0e5d8d1be81b (4 revisions) (flutter/flutter#194249) 2026-10-12 [email protected] Make DisplayLists' use of DlPaint, SkPaint, and impeller::Paint agree on the default isAntiAlias (flutter/flutter#193939) If this roll has caused a breakage, revert this CL and set the roller ...
…0791) ## Summary Part 22 of the modular dependency injection migration. * Migrates `RunCommand` and `RunCommandBase` to modular constructor dependency injection (`ToolContext`, `AppleContext`, `AndroidContext`, `BuildSystem`, `BuildTargets`, `DeviceManager`). * Makes `ToolDependencies.buildTargets` non-nullable and updates `executable.dart` to inject dependencies into `RunCommand` and `DriveCommand`. * Migrates unit tests in `run_test.dart`, `drive_test.dart`, and `flutter_command_test.dart`. Part of flutter#188471
Summary
Part 22 of the modular dependency injection migration.
RunCommandandRunCommandBaseto modular constructor dependency injection (ToolContext,AppleContext,AndroidContext,BuildSystem,BuildTargets,DeviceManager).ToolDependencies.buildTargetsnon-nullable and updatesexecutable.dartto inject dependencies intoRunCommandandDriveCommand.run_test.dart,drive_test.dart, andflutter_command_test.dart.Part of #188471