GnkImageCropWidget constructor

GnkImageCropWidget({
  1. required String imagePath,
  2. required GnkImageCropController cropController,
  3. Color overlayColor = const Color.fromRGBO(0, 0, 0, 0.5),
  4. Color backgroundColor = Colors.white,
  5. CustomCropShape shape = CustomCropShape.Circle,
  6. CustomImageFit imageFit = CustomImageFit.fitCropSpace,
  7. double cropPercentage = 0.8,
  8. CustomPaint drawPath(
    1. Path, {
    2. Paint? pathPaint,
    }) = DottedCropPathPainter.drawPath,
  9. Paint? pathPaint,
  10. bool canRotate = true,
  11. bool canScale = true,
  12. bool canMove = true,
  13. bool clipShapeOnCrop = true,
  14. Widget? customProgressIndicator,
  15. Ratio? ratio,
  16. double borderRadius = 0,
  17. Paint? imagePaintDuringCrop,
  18. bool forceInsideCropArea = false,
  19. Key? key,
})

A custom image cropper widget

Uses a CustomImageCropController to crop the image. With the controller you can rotate, translate and/or scale with buttons and sliders. This can also be achieved with gestures

Use a shape with CustomCropShape.Circle or CustomCropShape.Square

You can increase the cropping area using cropPercentage

Change the cropping border by changing drawPath, we've provided two default painters as inspiration DottedCropPathPainter.drawPath and SolidCropPathPainter.drawPath

Implementation

GnkImageCropWidget({
  required this.imagePath,
  required this.cropController,
  this.overlayColor = const Color.fromRGBO(0, 0, 0, 0.5),
  this.backgroundColor = Colors.white,
  this.shape = CustomCropShape.Circle,
  this.imageFit = CustomImageFit.fitCropSpace,
  this.cropPercentage = 0.8,
  this.drawPath = DottedCropPathPainter.drawPath,
  this.pathPaint,
  this.canRotate = true,
  this.canScale = true,
  this.canMove = true,
  this.clipShapeOnCrop = true,
  this.customProgressIndicator,
  this.ratio,
  this.borderRadius = 0,
  Paint? imagePaintDuringCrop,
  this.forceInsideCropArea = false,
  Key? key,
})  : this.imagePaintDuringCrop = imagePaintDuringCrop ??
          (Paint()..filterQuality = FilterQuality.high),
      assert(
        !(shape == CustomCropShape.Ratio && ratio == null),
        "If shape is set to Ratio, ratio should not be null.",
      ),
      super(key: key);