pickImageFromCamera method

Future<File?> pickImageFromCamera({
  1. required BuildContext context,
  2. required dynamic onCropImage(
    1. File croppedImage
    ),
  3. SeniorImageCropperStyle? style,
  4. int? maxSizeMb,
  5. VoidCallback? onPermissionCameraDenied,
  6. dynamic onException(
    1. Object e
    )?,
})

Implementation

Future<File?> pickImageFromCamera({
  required BuildContext context,
  required Function(File croppedImage) onCropImage,
  SeniorImageCropperStyle? style,
  int? maxSizeMb,
  VoidCallback? onPermissionCameraDenied,
  Function(Object e)? onException,
}) async {
  try {
    final pickedFile = await _picker.pickImage(
      source: ImageSource.camera,
      imageQuality: 50,
    );
    if (pickedFile != null) {
      return await _cropImage(
        imgFile: File(pickedFile.path),
        context: context,
        onCropImage: onCropImage,
        style: style,
        maxSizeMb: maxSizeMb,
      );
    }
  } on PlatformException catch (e) {
    if (e.code == 'camera_access_denied') {
      onPermissionCameraDenied?.call();
    }
  } catch (e) {
    onException?.call(e);
  }
  return null;
}