getImage<T> method
Future<T?>
getImage<
T>({ - String? title,
- String? content,
- CropStyle cropStyle = CropStyle.rectangle,
- int maxSize = 1080,
- required dynamic onCameraClicked(
- File?
)?,
- required dynamic onGalleryClicked(
- 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);
},
);
},
);
}