doneEditing method

  1. @protected
void doneEditing({
  1. dynamic returnValue,
  2. required EditorImage editorImage,
  3. Function? onCloseWithValue,
  4. dynamic onSetFakeHero(
    1. Uint8List?
    )?,
})

This function is for internal use only and is marked as protected. Please use the done() method instead.

Implementation

@protected
void doneEditing({
  dynamic returnValue,
  required EditorImage editorImage,
  Function? onCloseWithValue,
  Function(Uint8List?)? onSetFakeHero,
}) async {
  if (createScreenshot) return;
  initConfigs.onImageEditingStarted?.call();

  if (initConfigs.convertToUint8List) {
    createScreenshot = true;
    LoadingDialog loading = LoadingDialog();
    await loading.show(
      context,
      configs: configs,
      theme: theme,
      message: i18n.doneLoadingMsg,
    );
    if (imageInfos == null) await setImageInfos();
    if (!mounted) return;
    bool screenshotIsCaptured = screenshotHistoryPosition > 0 &&
        screenshotHistoryPosition <= screenshotHistory.length;
    Uint8List? bytes = await screenshotCtrl.captureFinalScreenshot(
      imageInfos: imageInfos!,
      backgroundScreenshot: screenshotIsCaptured
          ? screenshotHistory[screenshotHistoryPosition - 1]
          : null,
      originalImageBytes: screenshotHistoryPosition > 0
          ? null
          : await editorImage.safeByteArray(context),
    );

    createScreenshot = false;
    if (mounted) {
      loading.hide(context);

      await initConfigs.onImageEditingComplete
          ?.call(bytes ?? Uint8List.fromList([]));

      if (onSetFakeHero != null) {
        if (bytes != null && mounted) {
          await precacheImage(MemoryImage(bytes), context);
        }
        onSetFakeHero.call(bytes);
      }

      initConfigs.onCloseEditor?.call();
    }
  } else {
    if (onCloseWithValue == null) {
      Navigator.pop(context, returnValue);
    } else {
      onCloseWithValue.call();
    }
  }
}