hnvn / flutter_image_cropper

A Flutter plugin for Android and iOS supports cropping images
969 stars 375 forks source link

support custom width and height locked #485

Open javaone199 opened 2 weeks ago

javaone199 commented 2 weeks 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).