GnkImageCropWidget constructor
GnkImageCropWidget({
- required String imagePath,
- required GnkImageCropController cropController,
- Color overlayColor = const Color.fromRGBO(0, 0, 0, 0.5),
- Color backgroundColor = Colors.white,
- CustomCropShape shape = CustomCropShape.Circle,
- CustomImageFit imageFit = CustomImageFit.fitCropSpace,
- double cropPercentage = 0.8,
- CustomPaint drawPath(}) = DottedCropPathPainter.drawPath,
- Paint? pathPaint,
- bool canRotate = true,
- bool canScale = true,
- bool canMove = true,
- bool clipShapeOnCrop = true,
- Widget? customProgressIndicator,
- Ratio? ratio,
- double borderRadius = 0,
- Paint? imagePaintDuringCrop,
- bool forceInsideCropArea = false,
- 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);