getImageFromGallery function
dynamic
getImageFromGallery({})
Implementation
getImageFromGallery({
required Color buttonColor,
bool pickMultiple = false,
double? imageHeight,
double? imageWidth,
int? imageQuality,
}) async {
bool galleryEnabled = await fxCanAccessGallery();
File? file;
List<File> fileList = [];
if (galleryEnabled) {
final imagePicker = ImagePicker();
if (pickMultiple) {
final pickedFile = await imagePicker.pickMultiImage(
maxHeight: imageHeight,
maxWidth: imageWidth,
imageQuality: imageQuality,
);
if (pickedFile.isNotEmpty) {
for (XFile data in pickedFile) {
file = File(data.path);
fileList.add(file);
}
}
} else {
final pickedFile = await imagePicker.pickImage(
source: ImageSource.gallery,
maxHeight: imageHeight,
maxWidth: imageWidth,
imageQuality: imageQuality,
);
if (pickedFile != null) {
file = File(pickedFile.path);
}
}
} else {
Get.dialog(
FXAlertDialog(
title: 'กรุณาตรวจสอบสิทธิ์ในการเข้าแกลลอรี่',
buttonColor: buttonColor,
),
);
}
if (pickMultiple) {
return fileList;
} else {
return file;
}
}