openPaintingEditor method
void
openPaintingEditor()
Opens the painting editor.
This method opens the painting editor and allows the user to draw on the current image. After closing the painting editor, any changes made are applied to the image's layers.
Implementation
void openPaintingEditor() async {
List<PaintingLayerData>? paintingLayers =
await openPage<List<PaintingLayerData>>(
PaintingEditor.autoSource(
key: paintingEditor,
file: editorImage.file,
byteArray: editorImage.byteArray,
assetPath: editorImage.assetPath,
networkUrl: editorImage.networkUrl,
initConfigs: PaintEditorInitConfigs(
configs: configs,
callbacks: callbacks,
layers: activeLayers,
theme: _theme,
mainImageSize: sizesManager.decodedImageSize,
mainBodySize: sizesManager.bodySize,
transformConfigs: stateManager.transformConfigs,
appliedBlurFactor: stateManager.activeBlur,
appliedFilters: stateManager.activeFilters,
),
),
duration: const Duration(milliseconds: 150),
);
if (paintingLayers != null && paintingLayers.isNotEmpty) {
for (var i = 0; i < paintingLayers.length; i++) {
addLayer(
paintingLayers[i],
blockSelectLayer: true,
blockCaptureScreenshot: i != paintingLayers.length - 1,
);
}
_selectLayerAfterHeroIsDone(paintingLayers.last.id);
setState(() {});
mainEditorCallbacks?.handleUpdateUI();
}
}