getDeviceManager method

DeviceManager<DeviceConfiguration<DeviceRegistration>, DeviceRegistration>? getDeviceManager(
  1. String deviceType
)

Returns the device manager for deviceType.

If none is registered yet, it is taken from the sampling packages and registered. Returns null if no sampling package provides deviceType.

Implementation

DeviceManager? getDeviceManager(String deviceType) {
  // early out if already registered
  if (devices.containsKey(deviceType)) return devices[deviceType];

  info('$runtimeType - Creating device manager for device type: $deviceType');

  // look for a device manager of this type in the sampling packages
  DeviceManager? manager;
  for (var package in SamplingPackageRegistry().packages) {
    if (package.deviceType == deviceType) manager = package.deviceManager;
  }

  if (manager == null) {
    warning(
      "$runtimeType - No device manager found for device: '$deviceType'. "
      'This may be because this device is not supported on this phone. '
      'Or it may be because the sampling package containing this device manager '
      'has not been registered in the SamplingPackageRegistry.',
    );
  } else {
    registerDevice(deviceType, manager);
  }

  return manager;
}