switchCameraSensor method

Future<void> switchCameraSensor({
  1. CameraAspectRatios? aspectRatio,
  2. double? zoom,
  3. FlashMode? flash,
  4. SensorType? type,
})

Switch camera from Sensors.BACK Sensors.front All states can switch this

Implementation

Future<void> switchCameraSensor({
  CameraAspectRatios? aspectRatio,
  double? zoom,
  FlashMode? flash,
  SensorType? type,
}) async {
  final previous = cameraContext.sensorConfig;
  final next = SensorConfig(
    sensor: previous.sensor == Sensors.back ? Sensors.front : Sensors.back,
    type: type ?? SensorType.wideAngle,
  );
  await cameraContext.setSensorConfig(next);

  if (aspectRatio != null) {
    await next.setAspectRatio(aspectRatio);
  }
  if (zoom != null) {
    await next.setZoom(zoom);
  }
  if (flash != null) {
    await next.setFlashMode(flash);
  }
}