takePhoto method

void takePhoto()

Implementation

void takePhoto() async {
  int rotate = currentOrientation == DeviceOrientation.landscapeLeft
      ? -90
      : currentOrientation == DeviceOrientation.landscapeRight
      ? 90
      : 0;
  if (previewFile.value == null) {
    previewFile.value = await cameraController?.takePicture();
    await cameraController?.pausePreview();
    isFromGallery.value = false;
    if (previewFile.value != null) {
      isResizing.value = true;
      final resizeFile = await Utils.compressImageV2(
        previewFile.value!,
        100,
        // fromGallery: false,
        rotate: rotate,
        imageSizeCallBack: (p0) {
          localImageSize.value = p0;
        },
      );
      // previewFile.value = resizeFile;
      isResizing.value = false;

      ///
      imageLocation = currentLocation;
      createdDateTime = DateTime.now().toUtc().toIso8601String();
      callEngine(resizeFile);
      if (savePhotoAfterShot == true) {
        await SaverGallery.saveImage(
          await resizeFile.readAsBytes(),
          fileName: resizeFile.name,
          skipIfExists: true,
        );
      }
    }
  } else {
    await cameraController?.resumePreview();
  }
}