image zoom and cropping plugin for flutter
a simple and easy used flutter plugin to crop image on ios and android.
installation
add simple_image_crop
as a dependency in pubspec.yaml
.
using crop image app
create a widget to load and edit an image:
final imgcropkey = globalkey<cropstate>();
widget _buildcropimage() {
return container(
color: colors.black,
child: imgcrop(
key: cropkey,
chipradius: 150, // crop area radius
chipshape: 'circle', // crop type "circle" or "rect"
image: image.file(imagefile), // you selected image file
),
);
}
generate a cropped image:
- select image recommendation
image-picker
, image file may be from the previous page:
final map args = modalroute.of(context).settings.arguments
- a
async
function get cropped file image:
crop.cropcompleted('selected file image', {picturequality: 'int of picture quality'})
floatingactionbutton: floatingactionbutton(
onpressed: () async {
final crop = cropkey.currentstate;
final croppedfile =
await crop.cropcompleted(args['image'], picturequality: 900);
// show you croppedfile ……
showimage(context, croppedfile);
},
Comments are closed.