Skip to content

Commit 6a22f41

Browse files
author
Jonah Williams
authored
add desktop artifacts to run/target_platform selectors (flutter#31505)
1 parent ca0e778 commit 6a22f41

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

packages/flutter_tools/lib/src/runner/flutter_command.dart

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -621,26 +621,9 @@ mixin DeviceBasedDevelopmentArtifacts on FlutterCommand {
621621
};
622622
for (Device device in devices) {
623623
final TargetPlatform targetPlatform = await device.targetPlatform;
624-
switch (targetPlatform) {
625-
case TargetPlatform.android_arm:
626-
case TargetPlatform.android_arm64:
627-
case TargetPlatform.android_x64:
628-
case TargetPlatform.android_x86:
629-
artifacts.add(DevelopmentArtifact.android);
630-
break;
631-
case TargetPlatform.web:
632-
artifacts.add(DevelopmentArtifact.web);
633-
break;
634-
case TargetPlatform.ios:
635-
artifacts.add(DevelopmentArtifact.iOS);
636-
break;
637-
case TargetPlatform.darwin_x64:
638-
case TargetPlatform.fuchsia:
639-
case TargetPlatform.tester:
640-
case TargetPlatform.windows_x64:
641-
case TargetPlatform.linux_x64:
642-
// No artifacts currently supported.
643-
break;
624+
final DevelopmentArtifact developmentArtifact = _artifactFromTargetPlatform(targetPlatform);
625+
if (developmentArtifact != null) {
626+
artifacts.add(developmentArtifact);
644627
}
645628
}
646629
return artifacts;
@@ -663,31 +646,50 @@ mixin TargetPlatformBasedDevelopmentArtifacts on FlutterCommand {
663646
final Set<DevelopmentArtifact> artifacts = <DevelopmentArtifact>{
664647
DevelopmentArtifact.universal,
665648
};
666-
switch (targetPlatform) {
667-
case TargetPlatform.android_arm:
668-
case TargetPlatform.android_arm64:
669-
case TargetPlatform.android_x64:
670-
case TargetPlatform.android_x86:
671-
artifacts.add(DevelopmentArtifact.android);
672-
break;
673-
case TargetPlatform.web:
674-
artifacts.add(DevelopmentArtifact.web);
675-
break;
676-
case TargetPlatform.ios:
677-
artifacts.add(DevelopmentArtifact.iOS);
678-
break;
679-
case TargetPlatform.darwin_x64:
680-
case TargetPlatform.fuchsia:
681-
case TargetPlatform.tester:
682-
case TargetPlatform.windows_x64:
683-
case TargetPlatform.linux_x64:
684-
// No artifacts currently supported.
685-
break;
649+
final DevelopmentArtifact developmentArtifact = _artifactFromTargetPlatform(targetPlatform);
650+
if (developmentArtifact != null) {
651+
artifacts.add(developmentArtifact);
686652
}
687653
return artifacts;
688654
}
689655
}
690656

657+
// Returns the development artifact for the target platform, or null
658+
// if none is supported
659+
DevelopmentArtifact _artifactFromTargetPlatform(TargetPlatform targetPlatform) {
660+
switch (targetPlatform) {
661+
case TargetPlatform.android_arm:
662+
case TargetPlatform.android_arm64:
663+
case TargetPlatform.android_x64:
664+
case TargetPlatform.android_x86:
665+
return DevelopmentArtifact.android;
666+
case TargetPlatform.web:
667+
return DevelopmentArtifact.web;
668+
case TargetPlatform.ios:
669+
return DevelopmentArtifact.iOS;
670+
case TargetPlatform.darwin_x64:
671+
if (!FlutterVersion.instance.isStable) {
672+
return DevelopmentArtifact.macOS;
673+
}
674+
return null;
675+
case TargetPlatform.windows_x64:
676+
if (!FlutterVersion.instance.isStable) {
677+
return DevelopmentArtifact.windows;
678+
}
679+
return null;
680+
case TargetPlatform.linux_x64:
681+
if (!FlutterVersion.instance.isStable) {
682+
return DevelopmentArtifact.linux;
683+
}
684+
return null;
685+
case TargetPlatform.fuchsia:
686+
case TargetPlatform.tester:
687+
// No artifacts currently supported.
688+
return null;
689+
}
690+
return null;
691+
}
692+
691693
/// A command which runs less analytics and checks to speed up startup time.
692694
abstract class FastFlutterCommand extends FlutterCommand {
693695
@override

0 commit comments

Comments
 (0)