takePicture method

Future<void> takePicture()

Implementation

Future<void> takePicture() async {
  defaultPanel();
  if (cameraController!.value.isTakingPicture) {
    // A capture is already pending, do nothing.
    return;
  }
  XFile file = await cameraController!.takePicture();

  int rotate = 0;
  if (orientation == NativeDeviceOrientation.landscapeRight) {
    rotate = 90;
  } else if (orientation == NativeDeviceOrientation.landscapeLeft) {
    rotate = -90;
  }

  if( rotate != 0) {
    final fixedImageBytes = await FlutterImageCompress.compressWithFile(file.path, rotate: rotate);
    var f = File(file.path);
    f.writeAsBytes(fixedImageBytes!);
  }

  takePictureController.sink.add(File(file.path));
}