hnvn / flutter_image_cropper

A Flutter plugin for Android and iOS supports cropping images
1k stars 392 forks source link

Inconsistent image display when Cropping on Web #525

Open ramluro1 opened 3 months ago

ramluro1 commented 3 months ago

I am in the process of developing a Web app using Flutter, and I am currently using version 4.0.1 of the flutter_image_cropper package.

I cannot upgrade to a newer version due to other dependencies (HTTP package).

When I invoke cropping, the image is being displayed inconsistently. I expect the full image to be displayed, but on occasion, it is zoomed in.
Full image image

Zoomed-in image image

How do I avoid this inconsistent behavior?

Here is the code that is calling the Crop function:

  Future<CroppedFile?> _cropProfileImage({required String imageUrl}) async {
    const height = 350;
    const width = 350;

    if (imageUrl != '') {
      final croppedFile = await ImageCropper().cropImage(
        sourcePath: _imageUrl,
        compressFormat: ImageCompressFormat.jpg,
        compressQuality: 100,
        uiSettings: [
          WebUiSettings(
            context: context,
            presentStyle: CropperPresentStyle.dialog,
            boundary: CroppieBoundary(width: width, height: width),
            viewPort: const CroppieViewPort(
                width: width - 20, height: height - 20, type: 'square'),
            enableExif: true,
            enableZoom: true,
            showZoomer: true,
          ),
        ],
      );
      if (croppedFile != null) {
        return croppedFile;
      }
    } else {
      return null;
    }
    return null;
  }