openCropRotateEditor method
void
openCropRotateEditor()
Opens the crop rotate editor.
This method opens the crop editor, allowing the user to crop and rotate the image.
Implementation
void openCropRotateEditor() async {
if (!_inited) await _decodeImageCompleter.future;
_openPage<TransformConfigs?>(
CropRotateEditor.autoSource(
key: cropRotateEditor,
file: _image.file,
byteArray: _image.byteArray,
assetPath: _image.assetPath,
networkUrl: _image.networkUrl,
initConfigs: CropRotateEditorInitConfigs(
configs: configs,
callbacks: callbacks,
theme: _theme,
layers: _stateManager.activeLayers,
transformConfigs: _stateManager
.stateHistory[_stateManager.position].transformConfigs,
mainImageSize: _sizesManager.decodedImageSize,
mainBodySize: _sizesManager.bodySize,
enableFakeHero: true,
appliedBlurFactor: _stateManager.activeBlur,
appliedFilters: _stateManager.activeFilters,
onDone: (transformConfigs, fitToScreenFactor) async {
List<Layer> updatedLayers = LayerTransformGenerator(
layers: _stateManager.activeLayers,
activeTransformConfigs: _stateManager.transformConfigs,
newTransformConfigs: transformConfigs,
layerDrawAreaSize: _sizesManager.bodySize,
undoChanges: false,
fitToScreenFactor: fitToScreenFactor,
).updatedLayers;
_decodeImage(transformConfigs);
_addHistory(
transformConfigs: transformConfigs,
layers: updatedLayers,
heroScreenshotRequired: true,
);
/// Important to reset the layer hero positions
if (activeLayers.isNotEmpty) {
_controllers.layerHeroResetCtrl.add(true);
await Future.delayed(const Duration(milliseconds: 60));
_controllers.layerHeroResetCtrl.add(false);
}
setState(() {});
},
),
),
).then((transformConfigs) async {
if (transformConfigs != null) {
setState(() {});
mainEditorCallbacks?.handleUpdateUI();
}
});
}