openPickImage method
Future<String?>
openPickImage(
- DeviceMediaSource source, {
- bool needCrop = false,
- CropType cropType = CropType.circle,
- bool isCameraFront = false,
- bool needCompress = false,
override
Implementation
@override
Future<String?> openPickImage(
DeviceMediaSource source, {
bool needCrop = false,
CropType cropType = CropType.circle,
bool isCameraFront = false,
bool needCompress = false,
}) async {
// Pick an image
final imgPath = await ImagePicker().pickImage(
source: source.toImageSource(),
preferredCameraDevice:
isCameraFront ? CameraDevice.front : CameraDevice.rear,
);
if (imgPath == null) {
return null;
}
final pathCompress =
needCompress == false ? imgPath.path : await _compress(imgPath);
if (pathCompress == null) {
throw Exception('Cannot compress file');
}
final pathCrop =
needCrop == false ? pathCompress : await _crop(pathCompress, cropType);
return pathCrop;
}