hm21 / pro_image_editor

The pro_image_editor is a Flutter widget designed for image editing within your application. It provides a flexible and convenient way to integrate image editing capabilities into your Flutter project.
https://hm21.github.io/pro_image_editor/
BSD 3-Clause "New" or "Revised" License
94 stars 59 forks source link

[Feature request] Possibility to set "aspectRatio" in "CropRotateEditorState". #169

Closed francescodinova closed 1 month ago

francescodinova commented 1 month ago

Platforms

Android, iOS, Web, Windows, macOS

Description

I would like to read aspectRatio attribute in CropAreaHistory mixin, and I would like a method to set it from code in CropRotateEditorState, so that it is added to the history and the state is updated accordingly (just as the openAspectRatioOptions() method does).

Why

In this way, it is possible to create a completely custom aspect ratio selector for the crop editor.

hm21 commented 1 month ago

Okay, I just released version 4.3.1 which now includes this feature. You can read and update the aspect ratio as below.

/// Read AspectRatio
double ratio = editorKey.currentState!.cropRotateEditor.currentState!.activeAspectRatio;

/// Update AspectRatio
editorKey.currentState!.cropRotateEditor.currentState!.updateAspectRatio(2 / 3);
francescodinova commented 1 month ago

Thanks it's perfect!