showCustomImagePicker method
Future<File?>
showCustomImagePicker(
{ - bool allowCamera = true,
- bool allowGallery = true,
- bool enableCrop = false,
- CropSettings? cropSettings,
- Color? primaryColor,
- Color? backgroundColor,
- String? title,
- double? maxWidth,
- double? maxHeight,
- int? imageQuality,
})
Implementation
Future<File?> showCustomImagePicker({
bool allowCamera = true,
bool allowGallery = true,
bool enableCrop = false,
CropSettings? cropSettings,
Color? primaryColor,
Color? backgroundColor,
String? title,
double? maxWidth,
double? maxHeight,
int? imageQuality,
}) async {
primaryColor ??= AppColors.primary;
backgroundColor ??= Colors.white;
final result = await Get.bottomSheet<File>(
Container(
padding: const EdgeInsets.symmetric(vertical: 24),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 40.w,
height: 4.h,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 16),
Text(
title ?? 'Select Image',
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 24),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (allowCamera)
_buildPickerOption(
icon: Icons.camera_alt_rounded,
label: 'Camera',
color: primaryColor,
onTap: () async {
Get.back();
final file = await pickImageFromCamera(
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: imageQuality,
enableCrop: enableCrop,
cropSettings: cropSettings,
);
if (file != null) {
Get.back(result: file);
}
},
),
if (allowGallery)
_buildPickerOption(
icon: Icons.photo_library_rounded,
label: 'Gallery',
color: primaryColor,
onTap: () async {
Get.back();
final file = await pickImageFromGallery(
maxWidth: maxWidth,
maxHeight: maxHeight,
imageQuality: imageQuality,
enableCrop: enableCrop,
cropSettings: cropSettings,
);
if (file != null) {
Get.back(result: file);
}
},
),
],
),
SizedBox(height: 16.w),
],
),
),
backgroundColor: Colors.transparent,
elevation: 0,
);
return result;
}