You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document what OperatingSystemUtils and OperatingSystemUtils.hostPlatform is representing #184358
I recently stumbled across the class OperatingSystemUtils in flutter_tools.
I noticed that the implementation of hostPlatform differs from platform to platform.
E.g. Windows uses Abi.current to determine its architecture variants, whereas all others use their custom implementation.
Wouldn't it make sense for all to use Abi.current.
See:
One reason I can think about it is not done on purpose, because the platform (TARGET) Dart runs on can differ from actual machine platform (HOST), e.g. when cross-platform building. But then Windows should use its own implementation without using Abi.current.
I am no expert there, I just want to be sure. Maybe Abi.current also reflects the real host (?), but I think it doesn't.
Therefore it would be good to have documented, what OperatingSystemUtils and OperatingSystemUtils.hostPlatform is representing and for what it can be used.
Proposal
I would like to propose to document the usage of this class properly and in a second step, if feasable, replace the implementation with Darts built-in Abi.current implementation on all platforms.
Good observation — this can definitely be confusing without clear documentation,
I think the key point here is the distinction between host platform (the machine running the tool) and target platform (the platform being built for). In some scenarios—especially cross-compilation—these can differ, which might explain why hostPlatform doesn’t consistently rely on Abi.current across all implementations.
My understanding is that Abi.current reflects the runtime environment of the Dart VM, which may not always map cleanly to the actual host machine characteristics that flutter_tools needs to reason about (e.g., when invoking platform-specific tooling).
So documenting:
what exactly OperatingSystemUtils.hostPlatform represents
how it differs from Dart’s Abi.current
and when each should be used
would be really valuable for contributors.
Regarding unifying the implementation using Abi.current, it might be worth validating whether it fully covers cases like cross-platform builds or toolchain-specific behavior before standardizing on it.
Overall, +1 for improving documentation first — that would make the intent much clearer before considering any refactor.
I think rewriting those getters to use Abi.current() is a reasonable cleanup (although looking at your linked commit, we definitely wouldn't need to check for Fuchsia or Android for the flutter CLI tool). I'd be happy to review a PR if you're willing to upload one!
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
refactor: Replace get hostPlatform with Dart's `Abi.current` (flutter…
VaradGupta23 commentedon Mar 31, 2026
Good observation — this can definitely be confusing without clear documentation,
I think the key point here is the distinction between host platform (the machine running the tool) and target platform (the platform being built for). In some scenarios—especially cross-compilation—these can differ, which might explain why
hostPlatformdoesn’t consistently rely onAbi.currentacross all implementations.My understanding is that
Abi.currentreflects the runtime environment of the Dart VM, which may not always map cleanly to the actual host machine characteristics thatflutter_toolsneeds to reason about (e.g., when invoking platform-specific tooling).So documenting:
OperatingSystemUtils.hostPlatformrepresentsAbi.currentwould be really valuable for contributors.
Regarding unifying the implementation using
Abi.current, it might be worth validating whether it fully covers cases like cross-platform builds or toolchain-specific behavior before standardizing on it.Overall, +1 for improving documentation first — that would make the intent much clearer before considering any refactor.
mbcorona commentedon Mar 31, 2026
Hi @Gustl22 , thanks for reporting.
I am routing this to the tool team so they can review your findings and determine the best path forward for the documentation and potential refactor.
bkonyi commentedon Apr 1, 2026
I think rewriting those getters to use
Abi.current()is a reasonable cleanup (although looking at your linked commit, we definitely wouldn't need to check for Fuchsia or Android for theflutterCLI tool). I'd be happy to review a PR if you're willing to upload one![flutter_tools] Fix tests failing after hostPlatform refactor
[flutter_tools] Fix xcodeproj tests failing after hostPlatform refactor
[flutter_tools] Fix xcresult tests failing after hostPlatform refactor
[flutter_tools] Fix cocoapods tests failing after hostPlatform refactor
[flutter_tools] Fix cache tests failing on Linux bots
37 remaining items
[flutter_tools] Fix build_test.dart failures caused by sysctl mock mi…
[flutter_tools] Use fake OS utils by default in XcodeProjectInterpret…
[flutter_tools] Revert test changes in xcodeproj.dart
[flutter_tools] Fix analyzer errors in xcodeproj_test.dart caused by …
[flutter_tools] Mock sysctl in xcodeproj_test.dart to avoid sequence …
[flutter_tools] Mock sysctl manually in specific tests in xcodeproj_t…
[flutter_tools] Hardcode xcrun in xcresult_test.dart to avoid sysctl …
[flutter_tools] Mock sysctl in cocoapods and xcode_validator tests to…
[flutter_tools] Fix sequence failures in xcresult, cocoapods, and xco…
[flutter_tools] Clean up sysctl mock constants in tests
[flutter_tools] Refactor hostPlatform to use Abi.current() (flutter#1…
[flutter_tools] Refactor hostPlatform to use Abi.current() (flutter#1…
github-actions commentedon Jul 14, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.