Sitelet https://github.com/flutter/flutter/pull/190771
Skip to content

[tool] Migrate InstallCommand to modular dependency injection - #190771

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
bkonyi:di/12-install
Sep 2, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
bkonyi:di/12-install

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 13 of the modular dependency injection migration.

Migrates InstallCommand to modular dependency injection container ToolContext, eliminating ambient global references and adding hermetic unit tests.

Part of #47161

@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 8, 2026
@bkonyi
bkonyi force-pushed the di/12-install branch 5 times, most recently from 8f028b6 to a7f931f Compare August 12, 2026 18:17
@github-actions github-actions Bot removed the team-android Owned by Android platform team label Aug 12, 2026
@github-actions github-actions Bot removed team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 28, 2026
@bkonyi
bkonyi marked this pull request as ready for review September 2, 2026 13:11
@bkonyi bkonyi added the CICD Run CI/CD label Sep 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors InstallCommand and the installApp function to accept and use ToolContext and an injected Logger instead of relying on ambient globals. The corresponding tests are updated to use a fake tool context and verify logging output. Feedback suggests making the logger parameter required in installApp to prevent warnings and errors from being silently dropped.

Comment thread packages/flutter_tools/lib/src/commands/install.dart
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors InstallCommand and the installApp function to inject ToolContext and Logger rather than relying on global variables, and updates the unit tests to use fakes. The review feedback suggests simplifying the InstallCommand constructor by using Dart's super-initializer parameters, which would eliminate the need for the redundant private _toolContext field and its getter.

Comment thread packages/flutter_tools/lib/src/commands/install.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/install.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/install.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/install.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/install.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors InstallCommand and the installApp function to use ToolContext and an injected Logger instead of relying on global variables. It also updates the corresponding tests to use fake contexts and loggers, removing context overrides. Feedback was provided regarding a test description that violates the Flutter style guide by starting with an uppercase letter and ending with a period.

Comment thread packages/flutter_tools/test/commands.shard/hermetic/install_test.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors InstallCommand and the installApp function to use ToolContext and Logger instead of relying on global variables, and updates the corresponding tests to use a fake tool context and buffer logger. The reviewer suggests introducing a private getter for the logger in InstallCommand to reduce code duplication across its methods.

Comment thread packages/flutter_tools/lib/src/commands/install.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors InstallCommand and the installApp function to depend on ToolContext and Logger instead of global variables, updating the test suite to use explicit fakes rather than context overrides. The review feedback recommends explicitly typing the toolContext parameter in the InstallCommand constructor as ToolContext to prevent compile-time nullability inference issues.

Comment thread packages/flutter_tools/lib/src/commands/install.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors "InstallCommand" and the "installApp" function to remove dependencies on global variables by explicitly passing and utilizing "ToolContext" and "Logger". The corresponding unit tests in "install_test.dart" have been updated to use "FakeToolContext" and "BufferLogger" instead of context overrides, and new tests have been added to verify logging behavior. I have no feedback to provide.

@bkonyi
bkonyi requested a review from chingjun September 2, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants