getImageFromGallery function

dynamic getImageFromGallery()

Implementation

getImageFromGallery() async {
  bool galleryEnabled = await fxCanAccessGallery();
  File? file;

  if (galleryEnabled) {
    final imagePicker = ImagePicker();
    final pickedFile = await imagePicker.pickImage(
      source: ImageSource.gallery,
      maxHeight: imageSize,
      maxWidth: imageSize,
    );

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

  return file;
}