forked from firka/flutter
in flutter run, throw tool exit when --flavor is provided but is not supported on the target device (#139045)
Fixes https://github.com/flutter/flutter/issues/134197
This commit is contained in:
@@ -372,6 +372,9 @@ class AndroidDevice extends Device {
|
||||
@override
|
||||
String get name => modelID;
|
||||
|
||||
@override
|
||||
bool get supportsFlavors => true;
|
||||
|
||||
@override
|
||||
Future<bool> isAppInstalled(
|
||||
ApplicationPackage app, {
|
||||
|
||||
@@ -610,6 +610,13 @@ class RunCommand extends RunCommandBase {
|
||||
webMode = featureFlags.isWebEnabled &&
|
||||
devices!.length == 1 &&
|
||||
await devices!.single.targetPlatform == TargetPlatform.web_javascript;
|
||||
|
||||
final String? flavor = stringArg('flavor');
|
||||
final bool flavorsSupportedOnEveryDevice = devices!
|
||||
.every((Device device) => device.supportsFlavors);
|
||||
if (flavor != null && !flavorsSupportedOnEveryDevice) {
|
||||
throwToolExit('--flavor is only supported for Android, macOS, and iOS devices.');
|
||||
}
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
|
||||
@@ -469,6 +469,10 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
' sdk: flutter\n',
|
||||
);
|
||||
}
|
||||
|
||||
if (stringArg('flavor') != null && !integrationTestDevice.supportsFlavors) {
|
||||
throwToolExit('--flavor is only supported for Android, macOS, and iOS devices.');
|
||||
}
|
||||
}
|
||||
|
||||
final Stopwatch? testRunnerTimeRecorderStopwatch = testTimeRecorder?.start(TestTimePhases.TestRunner);
|
||||
|
||||
@@ -758,6 +758,9 @@ abstract class Device {
|
||||
/// Whether the device supports the '--fast-start' development mode.
|
||||
bool get supportsFastStart => false;
|
||||
|
||||
/// Whether the Flavors feature ('--flavor') is supported for this device.
|
||||
bool get supportsFlavors => false;
|
||||
|
||||
/// Stop an app package on the current device.
|
||||
///
|
||||
/// Specify [userIdentifier] to stop app installed to a profile (Android only).
|
||||
|
||||
@@ -358,6 +358,9 @@ class IOSDevice extends Device {
|
||||
@override
|
||||
bool get supportsStartPaused => false;
|
||||
|
||||
@override
|
||||
bool get supportsFlavors => true;
|
||||
|
||||
@override
|
||||
Future<bool> isAppInstalled(
|
||||
ApplicationPackage app, {
|
||||
|
||||
@@ -392,6 +392,9 @@ class IOSSimulator extends Device {
|
||||
@override
|
||||
bool get supportsHotRestart => true;
|
||||
|
||||
@override
|
||||
bool get supportsFlavors => true;
|
||||
|
||||
@override
|
||||
Future<bool> get supportsHardwareRendering async => false;
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@ class MacOSDevice extends DesktopDevice {
|
||||
@override
|
||||
String get name => 'macOS';
|
||||
|
||||
@override
|
||||
bool get supportsFlavors => true;
|
||||
|
||||
@override
|
||||
Future<TargetPlatform> get targetPlatform async => TargetPlatform.darwin;
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ class MacOSDesignedForIPadDevice extends DesktopDevice {
|
||||
@override
|
||||
bool isSupported() => _operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm64;
|
||||
|
||||
@override
|
||||
bool get supportsFlavors => true;
|
||||
|
||||
@override
|
||||
bool isSupportedForProject(FlutterProject flutterProject) {
|
||||
return flutterProject.ios.existsSync() && _operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm64;
|
||||
|
||||
@@ -90,6 +90,9 @@ class FlutterTesterDevice extends Device {
|
||||
@override
|
||||
bool supportsRuntimeMode(BuildMode buildMode) => buildMode == BuildMode.debug;
|
||||
|
||||
@override
|
||||
bool get supportsFlavors => true;
|
||||
|
||||
@override
|
||||
Future<TargetPlatform> get targetPlatform async => TargetPlatform.tester;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user