image_picker2 1.0.1 copy "image_picker2: ^1.0.1" to clipboard
image_picker2: ^1.0.1 copied to clipboard

A modern, zero-permission Flutter plugin to pick images and videos with OS-level selection limits and native compression.

image_picker2 #

A modern, zero-permission Flutter plugin for picking images and videos with a strict user-defined selection limit. Powered by the native Android Photo Picker (MediaStore.ACTION_PICK_IMAGES) and iOS PHPicker — no storage permissions required.

pub package License: MIT Platform


✨ Features #

  • 📸 Pick images and videos with a single, unified API
  • 🔢 User-defined limit — strictly enforced at the OS level
  • 🚫 Zero permissions required — uses Android Photo Picker & iOS PHPicker
  • 🗜️ Built-in compression — configure maxWidth and quality for images
  • 🎯 Type filtering — pick image, video, or any
  • Limit-reached visual — native OS grays out unselectable items when limit is met
  • 📱 Android 11+ & iOS 14+ supported — with fallback for older devices

📦 Installation #

Add this to your pubspec.yaml:

dependencies:
  image_picker2: ^1.0.0

Then run:

flutter pub get

🚀 Quick Start #

import 'package:image_picker2/image_picker2.dart';

// Pick up to 3 images
final List<String>? images = await ImagePicker2.pickMedia(
  limit: 3,
  type: PickerMediaType.image,
  maxWidth: 1200,
  quality: 85,
);

// Pick up to 2 videos
final List<String>? videos = await ImagePicker2.pickMedia(
  limit: 2,
  type: PickerMediaType.video,
);

📖 API Reference #

ImagePicker2.pickMedia #

Parameter Type Default Description
limit int required Maximum number of items to select
type PickerMediaType image image, video, or any
maxWidth int? null Max width in pixels (images only)
quality int? null JPEG quality 1-100 (images only)

Returns: Future<List<String>?> - list of temporary file paths, or null if cancelled.

PickerMediaType #

enum PickerMediaType { image, video, any }

Legacy API (backwards compatible) #

final List<String>? images = await ImagePicker2.pickImages(
  limit: 5,
  maxWidth: 1080,
  quality: 90,
);

🔒 Permissions #

None required! This plugin uses:

Platform API Used Permission Needed
Android MediaStore.ACTION_PICK_IMAGES None
iOS PHPickerViewController None

The system picker runs in a separate process owned by the OS, so your app never touches the gallery directly.


📱 Platform Support #

Platform Min Version Picker API
Android API 24+ ACTION_PICK_IMAGES with fallback to ACTION_GET_CONTENT
iOS iOS 14+ PHPickerViewController

🔧 How Selection Limit Works #

  • Android: The OS enforces the limit. Once reached, other items are visually disabled.
  • iOS: PHPickerConfiguration.selectionLimit locks the picker once the limit is reached.
  • App-level guard: Even if the OS allows more (on some OEM devices), the plugin always trims the result to your limit.

📝 Example #

See the full example in the /example folder.

final result = await ImagePicker2.pickMedia(
  limit: 5,
  type: PickerMediaType.image,
  maxWidth: 1920,
  quality: 80,
);

if (result != null) {
  for (final path in result) {
    print('Selected: $path');
  }
}

🐛 Issues & Contributions #

Found a bug or have a feature request? 👉 Open an issue on GitHub

Pull requests are welcome!


📄 License #

MIT License - see LICENSE for details.


Made with ❤️ by Roshan Dudhat

2
likes
150
points
124
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A modern, zero-permission Flutter plugin to pick images and videos with OS-level selection limits and native compression.

Homepage

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on image_picker2

Packages that implement image_picker2