goneReasons method
Why each of devices is gone from the host, keyed by id; one adb devices and one simctl list at most, run together. A device the host could not be asked about, and a physical iPhone, is left out.
Implementation
Future<Map<String, String>> goneReasons(Iterable<({String id, DevicePlatform platform})> devices) async {
final android = [
for (final d in devices)
if (d.platform == DevicePlatform.android) d.id
];
final sims = [
for (final d in devices)
if (d.platform == DevicePlatform.ios && !isPhysicalIosUdid(d.id)) d.id
];
final states = await Future.wait([
android.isEmpty ? Future.value(null) : _adbStates(),
sims.isEmpty ? Future.value(null) : _simStates(),
]);
final adb = states[0];
final simctl = states[1];
return {
if (adb != null)
for (final id in android)
if (adb[id] != 'device')
id: adb[id] == null ? 'not listed by `adb devices`' : '`adb devices` lists it as ${adb[id]}',
if (simctl != null)
for (final id in sims)
if (simctl[id] != 'Booted') id: simctl[id] == null ? 'not listed by `simctl`' : 'simulator is ${simctl[id]}',
};
}