-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
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.