pick_snap 0.0.4 pick_snap: ^0.0.4 copied to clipboard
Pick Snap
PickSnap #
Your Flutter Image Picker with Convenience and Customization
PickSnap is a user-friendly Flutter package that streamlines the process of picking images from the camera or gallery in your mobile application. It handles permission requests, allowing you to focus on integrating image selection seamlessly into your app's workflow.
Features #
- Image Source Selection: Let users choose between capturing a new photo with the camera or selecting an existing image from their device's gallery.
- Permission Handling: PickSnap takes care of requesting the necessary storage permissions for both Android and iOS, ensuring a smooth user experience.
- Optional Cropping: If desired, enable a built-in cropping feature so users can adjust the image's dimensions before selection.
- Customization: Control various aspects of the image picker's appearance, such as toolbar colors and titles, to match your app's design aesthetics.
- Image Compression: Optimize image size by specifying a compression quality (between 0 and 100).
Getting Started #
- A Flutter project set up
Steps #
Add PickSnap to your pubspec.yaml
:
dependencies:
pick_snap: ^latest_version
Import the package:
import 'package:pick_snap/pick_snap.dart';
Platform-Specific Configuration #
Android #
Add the required permissions to your AndroidManifest.xml
file:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
iOS #
Add the following key-value pairs to your Info.plist
file:
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to pick photos.</string>
Uses #
Here's a basic example to get you started:
void imagePickMethod() async {
File? pickedImage = await PickSnap.pickImage(
context, // Pass the BuildContext of your widget
source: ImageSourceOption.gallery, // Choose source (camera or gallery)
imageCompressQuality: 50, // Optional: Compress image (0-100)
toolbarWidgetColor: Colors.green, // Optional: Customize toolbar color
cropperRequired: false, // Optional: Disable cropping if not needed
toolBarTitle: 'Crop Image', // Optional: Set toolbar title for cropping
toolBarColor: Colors.purple, // Optional: Customize toolbar color for cropping
);
if (pickedImage != null) {
debugPrint(pickedImage.path); // Do something with the picked image
}
}