image_upload 1.0.0
image_upload: ^1.0.0 copied to clipboard
A customizable Flutter widget for seamless image capture, gallery selection, interactive preview, and efficient uploading, enhancing user experience in mobile apps.
Here is your full README.md
file for your Flutter Image Upload Widget, including setup, permissions, usage, customization, and platform-specific instructions:
📄 README.md
#
# 📸 Flutter Image Upload Widget
A reusable, beautiful, and customizable Flutter widget to upload images using the device **camera** or **gallery**, with support for **edit, delete**, and **upload** actions.
> ✅ No third-party dependencies except `image_picker`.
---
## ✨ Features
- 📷 Pick images from **camera** or **gallery**
- 🖼️ Display image preview (supports multiple)
- 🗑️ **Delete** or ✏️ **Edit** (replace) images
- 🔘 Upload action with callback
- 🎨 Fully customizable UI (labels, colors, size)
- 🚫 No external compression/storage dependencies
---
## 📦 Installation
### 1. Add dependencies
In your `pubspec.yaml`:
```yaml
dependencies:
flutter:
sdk: flutter
image_upload: ^latest_version
Then run:
flutter pub get
2. Android Setup #
➕ AndroidManifest.xml
Path: android/app/src/main/AndroidManifest.xml
Add permissions outside <application>
:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
Add this inside <application>
:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
➕ Create file: android/app/src/main/res/xml/provider_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="." />
</paths>
3. iOS Setup #
➕ ios/Runner/Info.plist
Add the following entries inside <dict>
:
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to the photo library to select images.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to the microphone for video recording.</string>
🚀 Usage #
Import the widget:
import 'image_upload_widget.dart';
Use in your UI:
ImageUploadWidget(
allowMultiple: true,
onImagesSelected: (List<File> images) {
// Called after image(s) selected
debugPrint("Selected images: ${images.map((e) => e.path)}");
},
onUploadTap: (List<String> paths) {
// Called when upload button is pressed
debugPrint("Ready to upload: $paths");
},
);
🎛️ Customization #
Parameter | Type | Default | Description |
---|---|---|---|
allowMultiple |
bool |
false |
Allow picking multiple images |
title |
String |
"Upload Image" |
Title displayed on top |
cameraText |
String |
"Camera" |
Camera button label |
galleryText |
String |
"Gallery" |
Gallery button label |
uploadButtonText |
String |
"Upload" |
Upload button label |
onImagesSelected |
Function(List<File>) |
required | Triggered after image(s) selected |
onUploadTap |
Function(List<String>) |
required | Triggered when upload is tapped |
📂 Directory Structure #
lib/
┣ widgets/
┃ ┗ image_upload_widget.dart
┗ main.dart
📸 Screenshots #
Empty State | With Images |
---|---|
[Empty] | [With] |
🛡 Permissions #
Use permission_handler (optional) if you want to ask permissions manually on runtime:
// Optional: Check and request permissions
await Permission.camera.request();
await Permission.photos.request();
📃 License #
This widget is licensed under the MIT License — free for personal & commercial use.
💬 Contributions #
Found a bug or want to add a feature? Feel free to contact with me.
Happy Coding 💙
---
## 👨💻 Author
**Md. Rahul Reza**
* Website: [rahulreza.com](https://www.rahulreza.com)
* Contact: contact@rahulreza.com