When to use Image Picker Plus
Image Picker Plus is a versatile, pure‑Dart solution that brings image and video selection, editing, and caching to any Flutter project without the need for platform‑specific native code. The package wraps common media‑acquisition workflows—opening the device gallery, launching the camera, applying simple crop operations, and adding lightweight filters—into a single, easy‑to‑use API. Because it is written entirely in Dart, it works consistently across Android, iOS, web, Windows, macOS, and Linux, making it a reliable choice for cross‑platform apps that need to handle user‑generated media.
When building forms, onboarding screens, or social‑sharing features, developers often need to let users attach photos or short video clips. Image Picker Plus fits naturally into these scenarios by providing a declarative widget that can be dropped into a form field, or by exposing a set of async helper methods that return a `PickedMedia` object ready for upload or local display. Its built‑in cropping tool supports common aspect ratios, while the filter pipeline offers a handful of preset color adjustments, enabling a polished look without pulling in heavyweight image‑processing libraries.
From an architectural perspective, Image Picker Plus is agnostic. It does not enforce any state‑management pattern, so you can integrate it with Provider, Riverpod, Bloc, GetX, or even a simple `setState` approach. The returned media objects contain the file path (or web URL) and metadata such as MIME type and dimensions, allowing you to feed them directly into your domain layer, upload services, or caching mechanisms. If you enable the optional caching feature, the package stores thumbnails in a local SQLite‑backed cache, reducing repeated decoding costs and improving list‑view performance on low‑end devices.
Setting up the package is straightforward. After adding the dependency, you only need to import the library and optionally configure a theme that matches your app’s design language. The API is designed for both beginners and power users: a one‑line call like `await ImagePickerPlus.pickImage()` opens the gallery, while more advanced usage can specify source, max dimensions, crop constraints, and filter selections through a fluent builder. Because the package does not rely on native plugins, you avoid the typical Gradle or CocoaPods version conflicts, and you can run your integration tests on all platforms without a device emulator.
In production, keep a few considerations in mind. While the package handles most common permission requests automatically, you should still declare the appropriate permissions in AndroidManifest.xml and Info.plist for camera and photo‑library access. On the web, the picker falls back to the HTML file input element, so ensure your UI gracefully handles browsers that limit file size or type. The optional caching layer writes to the app’s temporary directory; you may want to clear it periodically or provide a user‑controlled “clear cache” button to avoid uncontrolled storage growth. Finally, test the cropping and filter UI on each target platform, as touch gestures and mouse interactions differ slightly.
For newcomers, a typical flow looks like this: a user taps a “Add Photo” button, the app calls `ImagePickerPlus.pickImage()` with a predefined theme, the user selects an image, optionally crops it to a square, applies a subtle sepia filter, and the resulting file path is stored in a form controller. When the form is submitted, the path is sent to a backend API or uploaded to cloud storage. This pattern can be replicated for video selection, with the same API surface, making Image Picker Plus a one‑stop shop for media input in Flutter applications.
Pros
- pure Dart – no native build steps
- single API for image and video
- built‑in cropping and filters
- optional caching improves performance
- consistent behavior across all Flutter platforms
Watch outs
- filter set is limited compared to full‑featured image editors
- large media files may need manual compression before upload
- caching feature adds extra dependency (sqflite)
Setup notes
Add the dependency with: ``` flutter pub add image_picker_plus ``` Then import the package: ```dart import 'package:image_picker_plus/image_picker_plus.dart'; ``` If you plan to use the optional caching feature, initialize it early in `main()`: ```dart await ImagePickerPlusCache.init(); ``` For Android and iOS, declare the required permissions in `AndroidManifest.xml` and `Info.plist` respectively (camera, read/write external storage). No additional native setup is needed for web or desktop.
Works with Flutter 2.5+ and Dart 2.14+. Fully null‑safe. Supports Android API 21+, iOS 11+, web browsers with File API, and desktop platforms (Windows, macOS, Linux). Requires internet permission for web uploads. Optional caching uses `path_provider` and `sqflite`, which are also cross‑platform.
```dart
import 'package:flutter/material.dart';
import 'package:image_picker_plus/image_picker_plus.dart';
class MediaForm extends StatefulWidget {
const MediaForm({Key? key}) : super(key: key);
@override
State<MediaForm> createState() => _MediaFormState();
}
class _MediaFormState extends State<MediaForm> {
PickedMedia? _media;
Future<void> _pick() async {
final media = await ImagePickerPlus()
.source(ImageSource.gallery)
.cropAspectRatio(1, 1)
.applyFilter(Filter.sepia)
.pick();
if (media != null) {
setState(() => _media = media);
}
}
@override
Widget build(BuildContext context) {
return Column(
children: [
ElevatedButton(onPressed: _pick, child: const Text('Add Photo')),
if (_media != null)
Image.file(File(_media!.path), height: 150),
],
);
}
}
```