getClientWithDeviceId method

Future getClientWithDeviceId(
  1. String deviceId,
  2. bool setAsCurrent
)

Implementation

Future<ffi.Client> getClientWithDeviceId(
  String deviceId,
  bool setAsCurrent,
) async {
  ffi.Client? client;
  int foundIdx = 0;
  for (final c in _clients) {
    if (c.deviceId().toString() == deviceId) {
      client = c;
      break;
    }
    foundIdx += 1;
  }
  if (client == null) {
    throw 'Unknown client $deviceId';
  }
  if (setAsCurrent) {
    _index = foundIdx;
  }

  return client;
}