imagePickAndCrop function

Future<XFile?> imagePickAndCrop(
  1. BuildContext context,
  2. double? aspectRatio
)

A utility function that allows the user to pick an image from their gallery and crop it. On the web, the context is required to display the cropper.

Implementation

Future<XFile?> imagePickAndCrop(
  BuildContext context,
  double? aspectRatio,
) async {
  return imagePicker(context).then((image) {
    if (image == null) return null;

    return imageCropper(context, image, aspectRatio);
  });
}