Skip to content

Document what OperatingSystemUtils and OperatingSystemUtils.hostPlatform is representing #184358

Closed

Description

@Gustl22

Use case

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:

HostPlatform get hostPlatform;

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.

See commit: dd69590

Activity

  1. VaradGupta23 commented on Mar 31, 2026

    @VaradGupta23

    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.

  2. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    d: api docsIssues with https://api.flutter.dev/
    c: proposalA detailed proposal for a change to Flutter
    team-toolOwned by Flutter Tool team
    on Mar 31, 2026
  3. mbcorona commented on Mar 31, 2026

    @mbcorona
    Member

    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.

  4. bkonyi commented on Apr 1, 2026

    @bkonyi
    Contributor

    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!

  5. added
    P3Issues that are less important to the Flutter project
    triaged-toolTriaged by Flutter Tool team
    on Apr 1, 2026
  6. 37 remaining items

  7. github-actions commented on Jul 14, 2026

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterd: api docsIssues with https://api.flutter.dev/team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions