editFileImageAndGetFile method

  1. @override
Future<File?> editFileImageAndGetFile({
  1. required File file,
  2. required ImageEditorOption imageEditorOption,
})

The file is the source of image.

The imageEditorOption is the option for edit image.

The method will return a File as image result.

If result is null, it means handle image error.

Implementation

@override
Future<File?> editFileImageAndGetFile({
  required File file,
  required ImageEditorOption imageEditorOption,
}) async {
  File? tmp = file;
  for (final group in imageEditorOption.groupList) {
    if (group.canIgnore) {
      continue;
    }
    final handler = ImageHandler.file(tmp);
    final editOption = ImageEditorOption();
    for (final option in group) {
      editOption.addOption(option);
    }
    editOption.outputFormat = imageEditorOption.outputFormat;
    final target = await _createTmpFilePath();
    tmp = await handler.handleAndGetFile(editOption, target);
  }
  return tmp;
}