image_picker_platforms 1.0.0
image_picker_platforms: ^1.0.0 copied to clipboard
Multi-purpose Image Picker package for Dart/Flutter, supporting Web, Android and iOS. Simplify image picking with cross-platform compatibility.
Image Picker Platforms A versatile Flutter package for selecting images from various sources (gallery, camera, or files) across multiple platforms including iOS, Android, and web. This package simplifies the process of integrating image picking functionality into your Flutter applications with a unified API. Features
Cross-Platform Support: Seamlessly pick images on iOS, Android, and web platforms. Multiple Sources: Select images from the device gallery, camera, or file system. Customizable Options: Configure image quality, size limits, and file types. Error Handling: Robust error management for permission issues and unsupported platforms. Lightweight and Fast: Optimized for performance with minimal dependencies.
Getting Started Prerequisites
Flutter SDK (version 3.0.0 or higher) Dart SDK (version 2.17.0 or higher) Add the package to your pubspec.yaml:dependencies: image_picker_platforms: ^1.0.0
Installation
Run flutter pub add image_picker_platforms to add the package to your project. For iOS, add the following permissions to your Info.plist:
For Android, ensure the following permissions are included in AndroidManifest.xml:
Setup for Web No additional setup is required for web, as the package uses HTML input for file selection. Usage Here's a simple example to demonstrate how to use the image_picker_platforms package to pick an image from the gallery: import 'package:image_picker_platforms/image_picker_platforms.dart';
void pickImage() async { try { final pickedFile = await ImagePickerPlatform.pickSingleFile();
if (pickedFile != null) {
print('Image path: ${pickedFile.path}');
// Use the picked image file
} else {
print('No image selected.');
}
} catch (e) { print('Error picking image: $e'); } }
For a complete example, including camera support and configuration options, check the /example folder in the package repository. Example with Configuration import 'package:image_picker_platforms/image_picker_platforms.dart';
void resizeImage() async { try { final pickedFile = await ImagePickerPlatform.pickSingleFile(); if (pickedFile == null) return; final image = await ResizeImagePlatform.resize(data?.data); if (image != null) { print('Image: ${image}'); // Use the picked image file } else { print('No image selected.'); } } catch (e) { print('Error picking image: $e'); } }
Additional Information
Documentation: For detailed API documentation, visit pub.dev. Contributing: Contributions are welcome! Please check the CONTRIBUTING.md file for guidelines. Issues: Report bugs or request features on the GitHub Issues page. Support: For questions or support, reach out via the GitHub Discussions or contact the maintainers at support@example.com. License: This package is licensed under the MIT License. See the LICENSE file for details.