getCamera method Null safety

  1. @visibleForTesting
Camera getCamera(
  1. int cameraId

Returns a camera for the given cameraId.

Throws a CameraException if the camera does not exist.


Camera getCamera(int cameraId) {
  final Camera? camera = cameras[cameraId];

  if (camera == null) {
    throw PlatformException(
      code: CameraErrorCode.notFound.toString(),
      message: 'No camera found for the given camera id $cameraId.',

  return camera;