Skip to content

A simple and easy to use flutter plugin to crop image on iOS and Android. Please comes leave stars ❤️

License

Notifications You must be signed in to change notification settings

yoni1988/flutter_simple_image_crop

 
 

Repository files navigation

Image Zoom and Cropping plugin for Flutter

A simple and easy used flutter plugin to crop image on iOS and Android.

Image Cropping circle area Image Cropping rect area Image Cropping rect gif Image Cropping area gif

Installation

Add simple_image_crop simple_image_crop as a dependency in pubspec.yaml.

Using

Create a widget to load and edit an image:

image can be of any type:

  ImgCrop(...),  //  ImageProvider
  ImgCrop.file(...) // Image file
  ImgCrop.asset(...) // Image assets your local
final imgCropKey = GlobalKey<ImgCropState>();

Widget _buildCropImage() {
  return Container(
      color: Colors.black,
      child: ImgCrop(
        key: cropKey,
        chipRadius: 150,  // crop area radius
        chipShape: ChipShape.rect,
        chipRatio: 2 / 1,
        image: FileImage(imageFile), // you selected image file
      ),
  );
}

Generate a cropped image:

a async function get cropped file image:

  • croppedImage is you cropped image File
  • pictureQuality Can control image size and quality
  final croppedFile = await crop.cropCompleted(
    croppedImage,
    {pictureQuality: 900}
  )
floatingActionButton: FloatingActionButton(
  onPressed: () async {
    final crop = cropKey.currentState;
    final croppedFile =
        await crop.cropCompleted(args['image'], pictureQuality: 900);

    // show you croppedFile ……
    showImage(context, croppedFile);
  },

it's so esay !

About

A simple and easy to use flutter plugin to crop image on iOS and Android. Please comes leave stars ❤️

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 37.9%
  • Java 31.1%
  • Objective-C 21.4%
  • Ruby 8.4%
  • Shell 1.2%