diff --git a/flutter-idea/src/io/flutter/run/daemon/DeviceSelection.java b/flutter-idea/src/io/flutter/run/daemon/DeviceSelection.java index 6527583e7c..21c16e7aac 100644 --- a/flutter-idea/src/io/flutter/run/daemon/DeviceSelection.java +++ b/flutter-idea/src/io/flutter/run/daemon/DeviceSelection.java @@ -46,9 +46,12 @@ DeviceSelection withDevices(@NotNull List newDevices) { final Optional selectedDevice = findById(newDevices, selectedId); // If there's no selected device, default the first ephemoral one in the list. - final FlutterDevice firstEphemoral = + FlutterDevice firstEphemeral = newDevices.stream().filter(FlutterDevice::ephemeral).findFirst().orElse(null); - return new DeviceSelection(ImmutableList.copyOf(newDevices), selectedDevice.orElse(firstEphemoral)); + if (firstEphemeral == null && !newDevices.isEmpty()) { + firstEphemeral = newDevices.get(0); + } + return new DeviceSelection(ImmutableList.copyOf(newDevices), selectedDevice.orElse(firstEphemeral)); } /**