hnvn / flutter_image_cropper

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

support custom width and height locked #485

Open javaone199 opened 6 months ago

javaone199 commented 6 months ago

Use case:

All photos must have exact size 400 * 600.

 ImageCropper().cropImage(
      sourcePath: file.path,
      maxWidth: 400,
      maxHeight: 600,
      aspectRatioPresets: [],
      uiSettings: [
        AndroidUiSettings(
            lockAspectRatio: true),
        IOSUiSettings(
        ),
        WebUiSettings(
          context: context,
        ),
      ],
    );

Error: Unhandled Exception: PlatformException(error, Index [selectedByDefault = 0] (0-based) cannot be higher or equal than aspect ratio options count [count = 0]., null, java.lang.IllegalArgumentException: Index [selectedByDefault = 0] (0-based) cannot be higher or equal than aspect ratio options count [count = 0].

Suggestion: add CropAspectRatioPreset.maxSize (use the specified maxWidth and maxHeight).