arsync_image_picker
A flexible, extensible image picker for Flutter with plug-and-play addons.
Features
- π― Simple API with powerful customization
- π§ Extensible processors and validators
- π± Multiple UI styles (Material Design, Cupertino)
- π Plug-and-play addon system
- π¦ Lightweight core with optional heavy features
- β Built-in file size validation
- π Format conversion (JPG/PNG)
- π File renaming support
Installation
Add this to your pubspec.yaml
:
dependencies:
arsync_image_picker: ^latest_version
Quick Start
import 'package:arsync_image_picker/arsync_image_picker.dart';
// Create a picker instance
final picker = ArsyncImagePicker();
// Add optional validators
picker.addValidator(FileSizeValidator(maxSizeMB: 5.0));
// Pick a single image
final image = await picker.pickImage(context: context);
// Pick multiple images
final images = await picker.pickImages(context: context);
Basic Usage
Single Image
final picker = ArsyncImagePicker();
final image = await picker.pickImage(
context: context,
onImageSelected: () {
// Show loading indicator
print('Processing image...');
},
);
if (image != null) {
// Use your image
print('Image path: ${image.path}');
}
Multiple Images
final images = await picker.pickImages(
context: context,
onImagesSelected: () {
print('Processing images...');
},
);
if (images != null) {
print('Selected ${images.length} images');
}
Direct Gallery/Camera Access
// Pick from gallery only
final image = await picker.pickImageFromGallery(context: context);
// Take photo with camera only
final image = await picker.pickImageFromCamera(context: context);
Built-in Features
File Size Validation
picker.addValidator(FileSizeValidator(maxSizeMB: 5.0));
File Renaming
picker.addProcessor(FileNameProcessor(newFileName: 'profile_pic'));
Format Conversion
picker.addProcessor(FormatConverterProcessor(
targetFormat: ImageFormatType.jpg,
));
Custom UI
Material Design (Default)
final picker = ArsyncImagePicker(
uiProvider: DefaultImagePickerUI(),
);
Cupertino Style
final picker = ArsyncImagePicker(
uiProvider: CupertinoImagePickerUI(),
);
Custom UI Config
final picker = ArsyncImagePicker(
uiConfig: ImagePickerUIConfig(
title: 'Select Photo',
galleryButtonText: 'Choose from Library',
cameraButtonText: 'Take New Photo',
),
);
Available Addons
Extend functionality with these optional addon packages:
Image Compression
Add smart image compression to reduce file sizes:
dependencies:
arsync_image_picker: ^latest_version
arsync_image_compression: ^latest_version
import 'package:arsync_image_compression/arsync_image_compression.dart';
picker.addProcessor(ImageCompressionProcessor(
targetMaxSizeMB: 2.0,
quality: 80,
));
Image Cropping
Add interactive image cropping functionality:
dependencies:
arsync_image_picker: ^latest_version
arsync_image_cropper: ^latest_version
import 'package:arsync_image_cropper/arsync_image_cropper.dart';
picker.addProcessor(ImageCroppingProcessor(
options: CropOptions(
aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), // Square crop
title: 'Crop Your Image',
),
));
Permissions
Android
No permissions are required.
iOS
Add these to ios/Runner/Info.plist
:
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to take photos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs photo library access to select images</string>
Creating Custom Processors
class CustomProcessor implements ImageProcessor {
@override
Future<bool> shouldProcess(XFile image, bool isMultiple, int index) async {
// Return true if this image should be processed
return true;
}
@override
Future<XFile> process(XFile image, bool isMultiple, int index) async {
// Process the image and return the result
return image;
}
}
// Use it
picker.addProcessor(CustomProcessor());
Creating Custom Validators
class CustomValidator implements ImageValidator {
@override
Future<bool> validate(XFile image) async {
// Return true if image is valid
return true;
}
@override
String get errorMessage => 'Custom validation failed';
}
// Use it
picker.addValidator(CustomValidator());
Author
Atif Siddiqui
- Email: itsatifsiddiqui@gmail.com
- GitHub: itsatifsiddiqui
- LinkedIn: Atif Siddiqui
About Arsync Solutions
Arsync Solutions, We build Flutter apps for iOS, Android, and the web.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! If you find a bug or want a feature, please open an issue.