deviceById function

Device? deviceById(
  1. String id
)

The device id names, or null for fitDeviceId and for anything unknown — which the caller must tell apart, because one is a choice and the other is a mistake. See isDeviceId.

Old ids resolve to what replaced them — see _renamed. A stored address is the case that matters: ?device=macbook-pro was written down by somebody who wanted a desktop stage, and answering "no such device" to it would make a rename look like a broken link.

Implementation

Device? deviceById(String id) {
  var wanted = _renamed[id] ?? id;
  return Devices.all.where((d) => d.id == wanted).firstOrNull;
}