crop_your_image
a flutter plugin which provides crop widget for cropping images.
crop_your_image provides only minimum ui for deciding cropping area inside images. other ui parts, such as “crop” button or “change aspect ratio” button, need to be prepared by each app developers.
this policy helps app developers to build “cropping page” with the design of their own brand.in order to control the actions for cropping images, you can use cropcontroller from whatever your widgets.
note
please note that this package is developping (not achieved even alpha). it doesn’t have enough functionality, is quite buggy, isn’t available confortably.
the basic idea is written above. i will appreciate your idea or suggestions to achieve it.
usage
place crop
widget wherever you want to place image cropping ui.
widget build(buildcontext context) {
return crop(
image: _imagedata,
aspectratio: 4 / 3,
initialsize: 0.5,
withcircleui: false,
oncropped: (image) {
// do something with image data
}
);
}
usage of each properties are listed below.
image
is image data whose type isuint8list
, and the result of cropping can be obtained viaoncropped
callback.aspectratio
is the aspect ratio of cropping area. setnull
or just omit if you want to crop images with any aspect ratio.aspectratio
can be changed dynamically via setter ofcropcontroller.aspectratio
. (see below)initialsize
is the initial size of cropping area.1.0
(ornull
, by default) fits the size of image, which means cropping area extends as much as possible.0.5
would be the half. this value is also referred whenaspectratio
changes viacropcontroller.aspectratio
.withcircleui
flag is to decide the shape of cropping ui. iftrue
,aspectratio
is automatically set1.0
and the shape of cropping ui would be circle. note that this flag does not affect to the result of cropping image. if you want cropped images with circle shape, callcropcontroller.cropcircle
instead ofcropcontroller.crop
.
if you want to controll from your own designed widgets, create a cropcontroller
instance and pass it to controller
property of crop
.
final _controller = cropcontroller();
widget build(buildcontext context) {
return crop(
image: _imagedata,
oncropped: (image) {
// do something with image data
}
controller: _controller,
);
}
you can call _controller.crop()
to crop a image.
elevatedbutton(
child: text('crop it!')
onpressed: _cropcontroller.crop,
),
because _controller.crop()
only kicks the cropping process, this method returns immediately without any cropped image data. you can always obtain the result of cropping images via oncropped
callback of crop
widget.
Comments are closed.