getImageFromCamera function

dynamic getImageFromCamera({
  1. required Color buttonColor,
  2. double? imageHeight,
  3. double? imageWidth,
  4. int? imageQuality,
})

Implementation

getImageFromCamera({
  required Color buttonColor,
  double? imageHeight,
  double? imageWidth,
  int? imageQuality,
}) async {
  bool cameraEnabled = await fxCanAccessCamera();
  File? file;

  if (cameraEnabled) {
    final imagePicker = ImagePicker();
    final pickedFile = await imagePicker.pickImage(
      source: ImageSource.camera,
      maxHeight: imageHeight,
      maxWidth: imageWidth,
      imageQuality: imageQuality,
    );

    if (pickedFile != null) {
      file = File(pickedFile.path);
    }
  } else {
    Get.dialog(
      FXAlertDialog(
        title: 'กรุณาตรวจสอบสิทธิ์ในการใช้งานกล้อง',
        buttonColor: buttonColor,
      ),
    );
  }

  return file;
}