Skip to content

artifacts class refactoring in the flutter_tool #80875

Closed as not planned
Closed as not planned

Description

@jonahwilliams

When trying to migrate artifacts.dart to null safety (context #79866) I discovered that the API is currently in a pretty bad state. Based on the type of Artifact, the caller is required to provide zero or more of the build mode, target platform, and environment enums. This has made the null safety migration awkward, since all arguments must be nullable and its up to the callsite to unit test to ensure correctness.

I think we should fix this, though not to the point of completely rewriting the library.

Given that each value of the Artifacts enum has different requirements, we should split the single enum into various different enums based on what they require to be looked up, and then create specialized lookup methods.

For example, the dartSdkPath does not require a build mode or target platform, this could be part of a "HostPlatform" artifacts:

enum HostPlatformArtifact {
  dartSdkPath,
  flutterWebSdkPath,
  iproxy,
  ...
}

String getHostPlatformArtifact(HostPlatformArtifact artifact) { ... }

Similarly, the gen_snapshot binaries always require a target platform and build mode:

enum TargetPlatformArtifact {
  genSnapshot,
  ...
}

String getTargetPlatformArtifact(HostPlatformArtifact artifact, BuildMode mode, TargetPlatform platform) { ... }

Finally there are some artifacts that require a build mode but not a host platform, since that platform is somewhat implied:

enum DontKnowWhatToCalllYouArtifacts {
  linuxDesktopWrapper,
  windowsDesktopWrapper,
}

This would us to make all of the required arguments appropriately non-nullable.

Activity

  1. added
    P3Issues that are less important to the Flutter project
    c: tech-debtTechnical debt, code quality, testing, etc.
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Apr 21, 2021
  2. jonahwilliams commented on Apr 21, 2021

    @jonahwilliams
    ContributorAuthor

    WIP: #80876

  3. github-actions commented on Jul 14, 2025

    @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.

  4. locked as resolved and limited conversation to collaborators on Jul 14, 2025
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: tech-debtTechnical debt, code quality, testing, etc.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