getDeviceFromRoleName method

DeviceConfiguration<DeviceRegistration>? getDeviceFromRoleName(
  1. String roleName
)

Get the DeviceConfiguration based on the roleName. This includes both the primary device and the connected devices. Returns null if no device with roleName is found.

Implementation

DeviceConfiguration? getDeviceFromRoleName(String roleName) {
  if (deviceConfiguration.roleName == roleName) return deviceConfiguration;
  try {
    return connectedDevices
        .firstWhere((device) => device.roleName == roleName);
  } catch (_) {
    return null;
  }
}