picture_cropper 0.0.19 copy "picture_cropper: ^0.0.19" to clipboard
picture_cropper: ^0.0.19 copied to clipboard

Flutter package for capturing and cropping photos from camera or gallery.

Picture Cropper #

License Github

A Flutter package for cropping pictures, which includes features for capturing images from the camera or selecting images from the gallery.

Irregular Crop

Rectangle Crop

Installation #

To use Picture Cropper in your Flutter project, add picture_cropper as a dependency in your pubspec.yaml file.

dependencies:
  picture_cropper: ^latest_version

Import it in your Dart code:

import 'package:picture_cropper/picture_cropper.dart';

iOS Configuration #

Add the following keys to your Info.plist file:

<key>NSPhotoLibraryUsageDescription</key>
<string>Describe why your app needs access to the photo library</string>
<key>NSCameraUsageDescription</key>
<string>Describe why your app needs access to the camera</string>
<key>NSMicrophoneUsageDescription</key>
<string>Describe why your app needs access to the microphone (if applicable)</string>

Or in text format add the key:

<key>NSPhotoLibraryUsageDescription</key>
<string>Used to demonstrate image picker plugin</string>
<key>NSCameraUsageDescription</key>
<string>Used to demonstrate image picker plugin</string>
<key>NSMicrophoneUsageDescription</key>
<string>Used to capture audio for image picker plugin</string>

Android #

No additional configuration required.

*Stateful Widget Usage

late PictureEditorController pictureEditorController;

@override
void initState() {
  super.initState();
  pictureEditorController = PictureCropperController(
    onSelectedImage: (Uint8List image) async {
      // Callback after capturing or selecting an image
      // If you need image bytes...
    },
    // If return from pop method...
    /*onSelectedImage: (Uint8List image) async {
      final result = await Navigator.pushNamed(context, '/editor');
      if (result == true) {
        pictureCropperController.changeCropGuideLineType(pictureCropperController.cropGuidelineType);
      }
    },*/
  );
}

@override
void dispose() {
  pictureEditorController.pictureEditorControllerDispose();
  super.dispose();
}

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: SafeArea(  
      child: PicturePicker(controller: pictureEditorController),
    ),
  );
}
/// Method - pickImageFromGallery
InkWell(
  onTap: pictureEditorController.pickImageFromGallery,
  child: const Icon(
    Icons.photo,
    color: Colors.white,
    size: 32,
  ),
),

/// Method - takePicture
InkWell(
  onTap: pictureEditorController.takePicture
  child: const Icon(
    Icons.photo,
    color: Colors.white,
    size: 32,
  ),
),

/// Method - toggleCameraDirection
InkWell(
  onTap: pictureCropperController.toggleCameraDirection,
  child: const Icon(
    Icons.photo,
    color: Colors.white,
    size: 32,
  ),
),

Example - Editing Image Crop Area #

final pictureCropperController = PictureCropperController();

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: SafeArea(
      child: PictureProEditor(controller: pictureEditorController),
    ),
  );
}
/// Method - toggleIrregularCrop
/// false = Ractangle Crop
/// true = Irregular Crop
InkWell(
    onTap: () async {
    setState(() {
      pictureEditorController.toggleIrregularCrop(false);
      _isIrregularCrop = false;
    });
  },
  child: const Icon(
    Icons.crop_free,
    color: Colors.white,
    size: 32,
  ),
),

Example - Cropping Image #

final pictureCropperController = PictureCropperController();

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: SafeArea(
      child: PictureCrop(
        controller: pictureEditorController,
        onCropped: (uiImage) {
          // If you need uiImage ...
        }
      ),
    ),
  );
}
MIT License

Copyright (c) 2024 Jeonghun Kim

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5
likes
0
pub points
47%
popularity

Publisher

verified publisherjhk-im.dev

Flutter package for capturing and cropping photos from camera or gallery.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

camera, flutter, image, image_picker

More

Packages that depend on picture_cropper