Repository navigation
Make FlutterCommand.toolContext non-nullable and remove globals from command runner - #195551
Merged
auto-submit[bot] merged 204 commits intoNov 4, 2026
Merged
auto-submit[bot] merged 204 commits into
auto-submit[bot] merged 204 commits into
Conversation
…ice away from globals
… project Inject dependencies into FlutterApplicationMigration, buildMacOS, and XcodeBasedProject (IosProject and MacOSProject) to remove direct globals.dart usages.
…and inject FlutterVersion into MacOSDevice
…imulators, emulators, and LLDB
Updates buildXcodeProject in packages/flutter_tools/lib/src/ios/mac.dart to require ToolContext along with explicit Apple dependencies instead of accepting individual ToolContext fields with fallback instantiations. Also restores running SwiftPackageManagerIntegrationMigration unconditionally when building via IOSDevice and IOSSimulator.
…and-xcode-project
…ed in iOS device/emulator classes
…ix FlutterProject.fromDirectoryTest logger fallback
…, and ToolDependencies.bootstrap
…and-xcode-project
# Conflicts: # packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
…and-simulators # Conflicts: # packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
# Conflicts: # packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
# Conflicts: # packages/flutter_tools/lib/src/context/tool_dependencies.dart
…ication packages Eliminates ambient `globals` usage in `ios/application_package.dart`, `macos/application_package.dart`, `windows/application_package.dart`, and `flutter_application_package.dart` by injecting `FileSystem`, `Logger`, `OperatingSystemUtils`, `Platform`, and `PlistParser` explicitly.
…devices Migrates buildLinux, buildWindows, DesktopDevice, and CustomDevice away from globals.dart to explicit dependency injection via ToolContext. Part of flutter#188471
Eliminates ambient `globals` usage from `packages/flutter_tools/lib/src/build_info.dart` by requiring explicit `Config`, `FileSystem`, `OperatingSystemUtils`, and `Platform` parameters across `getCurrentHostPlatform` and the build directory helper functions. The unreachable unsupported-host fallback in `getCurrentHostPlatform` no longer logs a warning.
…-command-tool-context # Conflicts: # packages/flutter_tools/lib/executable.dart # packages/flutter_tools/lib/src/commands/channel.dart # packages/flutter_tools/lib/src/commands/create_base.dart # packages/flutter_tools/lib/src/commands/downgrade.dart # packages/flutter_tools/lib/src/commands/ide_config.dart # packages/flutter_tools/lib/src/commands/packages.dart # packages/flutter_tools/lib/src/commands/upgrade.dart # packages/flutter_tools/lib/src/flutter_application_package.dart # packages/flutter_tools/lib/src/globals.dart # packages/flutter_tools/lib/src/runner/flutter_command.dart # packages/flutter_tools/test/commands.shard/permeable/create_test.dart # packages/flutter_tools/test/general.shard/ios/mac_test.dart # packages/flutter_tools/test/src/test_flutter_command_runner.dart
bkonyi
marked this pull request as ready for review
November 3, 2026 17:08
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors dependency injection in FlutterCommand and its subclasses by making toolContext a required, non-nullable field and removing redundant overrides. It also updates FlutterCommandRunner to explicitly manage and expose key dependencies instead of relying on global variables. Feedback on the changes highlights a potential null-assertion crash when accessing runner!.templateRenderer! in FlutterCommand, suggesting a safer fallback to MustacheTemplateRenderer.
chingjun
previously approved these changes
Nov 3, 2026
…-command-tool-context
chingjun
approved these changes
Nov 4, 2026
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
FlutterCommand.toolContextnon-nullable (required this.toolContext) across allFlutterCommandsubclasses and wires runner-level dependencies (DeviceManager,Doctor,AndroidContext,CocoaPods,PlistParser, andTemplateRenderer) throughFlutterCommandRunnerandFlutterCommand, removingglobals.dartimports fromflutter_command.dartandflutter_command_runner.dart.Part of #47161