diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index dc776045bd..1de18da35d 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -190,6 +190,12 @@ class DeviceManager { if (isDeviceSupportedForProject(device, flutterProject)) device ]; + } else if (devices.length == 1 && + !hasSpecifiedDeviceId && + !isDeviceSupportedForProject(devices.single, flutterProject)) { + // If there is only a single device but it is not supported, then return + // early. + return []; } // If there are still multiple devices and the user did not specify to run diff --git a/packages/flutter_tools/test/general.shard/device_test.dart b/packages/flutter_tools/test/general.shard/device_test.dart index 0e41b14acc..602ac96a86 100644 --- a/packages/flutter_tools/test/general.shard/device_test.dart +++ b/packages/flutter_tools/test/general.shard/device_test.dart @@ -87,6 +87,17 @@ void main() { ]); }); + testUsingContext('Removes a single unsupported device', () async { + final List devices = [ + unsupported, + ]; + + final DeviceManager deviceManager = TestDeviceManager(devices); + final List filtered = await deviceManager.findTargetDevices(FlutterProject.current()); + + expect(filtered, []); + }); + testUsingContext('Removes web and fuchsia from --all', () async { final List devices = [ webDevice,