FilterAppliedImage constructor

FilterAppliedImage({
  1. Key? key,
  2. required Uint8List image,
  3. required ColorFilterGenerator filter,
  4. BoxFit? fit,
  5. dynamic onProcess(
    1. Uint8List
    )?,
  6. double opacity = 1,
})

Creates a FilterAppliedImage widget.

Implementation

FilterAppliedImage({
  super.key,
  required this.image,
  required this.filter,
  this.fit,
  this.onProcess,
  this.opacity = 1,
}) {
  if (onProcess != null) {
    if (filter.filters.isEmpty) {
      onProcess!(image);
      return;
    }

    final ImageEditorOption option = ImageEditorOption();
    option.addOption(ColorOption(matrix: filter.matrix));

    ImageEditor.editImage(
      image: image,
      imageEditorOption: option,
    ).then((result) {
      if (result != null) {
        onProcess!(result);
      }
    }).catchError((err, stack) {});
  }
}