getImage<T> method

Future<T?> getImage<T>({
  1. String? title,
  2. String? content,
  3. CropStyle cropStyle = CropStyle.rectangle,
  4. int maxSize = 1080,
  5. required dynamic onCameraClicked(
    1. File?
    )?,
  6. required dynamic onGalleryClicked(
    1. File?
    )?,
})

Implementation

Future<T?> getImage<T>({
  String? title,
  String? content,
  CropStyle cropStyle = CropStyle.rectangle,
  int maxSize = 1080,
  required Function(File?)? onCameraClicked,
  required Function(File?)? onGalleryClicked,
}) async {
  return await showAnimatedDialog(
    context: Get.context!,
    barrierDismissible: true,
    animationType: animationType,
    curve: Curves.fastOutSlowIn,
    duration: const Duration(milliseconds: 500),
    builder: (context) {
      final ImagePicker _picker = ImagePicker();
      return ConfirmDialog(
        title: title,
        content: content ?? "Choose the one to use:",
        lottiePath: GetxFire.lottiePath.IMAGE_ICON,
        labelLeftButton: "Camera",
        colorLeftButton:
            Get.isDarkMode ? null : Colors.blue[600]?.withOpacity(0.9),
        onLeftPressed: () async {
          XFile? pickedFile =
              await _picker.pickImage(source: ImageSource.camera);
          File? file = pickedFile == null
              ? null
              : await imageCropper(pickedFile.path,
                  cropStyle: cropStyle, maxSize: maxSize);
          Get.back();
          if (onCameraClicked != null) onCameraClicked(file);
        },
        labelRightButton: "Gallery",
        colorRightButton: Get.isDarkMode ? null : Colors.yellow[700],
        onRightPressed: () async {
          XFile? pickedFile =
              await _picker.pickImage(source: ImageSource.gallery);
          File? file = pickedFile == null
              ? null
              : await imageCropper(pickedFile.path,
                  cropStyle: cropStyle, maxSize: maxSize);
          Get.back();
          if (onGalleryClicked != null) onGalleryClicked(file);
        },
      );
    },
  );
}