Skip to content

Commit c56d9fa

Browse files
authored
Auto select first device when there is no selection yet (#7971)
This change automates the requirement to manually select a device, currently a mandatory manual step when not running from the command line (`flutter run` is capable of autonomously selecting a matching device) Fixes #7970.
1 parent 17ea0a6 commit c56d9fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: flutter-idea/src/io/flutter/run/daemon/DeviceService.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ private synchronized void refreshDeviceSelection() {
154154
deviceSelection.updateAndGet((old) -> {
155155
final DeviceDaemon daemon = deviceDaemon.getNow();
156156
final List<FlutterDevice> newDevices = daemon == null ? ImmutableList.of() : daemon.getDevices();
157-
return old.withDevices(newDevices);
157+
FlutterDevice oldSelection = old.getSelection();
158+
String selection = oldSelection != null
159+
? oldSelection.deviceId()
160+
: newDevices.isEmpty() ? null : newDevices.getFirst().deviceId();
161+
return old.withDevices(newDevices).withSelection(selection);
158162
});
159163
fireChangeEvent();
160164
}

0 commit comments

Comments
 (0)