picker 1.0.3+1

Media Picker plugin for Flutter #

A Flutter plugin for iOS and Android for picking images and videos from gallery or camera, and save files on gallery

Installation #

First, add picker as a dependency in your pubspec.yaml file.

iOS #

Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
  • NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
  • NSMicrophoneUsageDescription - describe why your app needs access to the microphone, if you intend to record videos. This is called Privacy - Microphone Usage Description in the visual editor.

Android #

No configuration required - the plugin should work out of the box.

Example #

import 'package:picker/picker.dart';

class MyHomePage extends StatefulWidget {
  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  File _image;

  Future getImage() async {
    var image = await picker.pickImage(source: ImageSource.camera,  maxHeight: 480, maxWidth: 640, quality: 75);

    // if you want save on gallery:
    var filePath = await MediaPicker.saveFile(fileData: image);

    setState(() {
      _image = image;

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Image Picker Example'),
      body: Center(
        child: _image == null
            ? Text('No image selected.')
            : Image.file(_image),
      floatingActionButton: FloatingActionButton(
        onPressed: getImage,
        tooltip: 'Pick Image',
        child: Icon(Icons.add_a_photo),

Handling MainActivity destruction on Android #

Android system -- although very rarely -- sometimes kills the MainActivity after the picker finishes. When this happens, we lost the data selected from the picker. You can use retrieveLostData to retrieve the lost data in this situation. For example:

Future<void> retrieveLostData() async {
  final LostDataResponse response =
      await ImagePicker.retrieveLostData();
  if (response == null) {
  if (response.file != null) {
    setState(() {
      if (response.type == RetrieveType.video) {
      } else {
  } else {

There's no way to detect when this happens, so calling this method at the right place is essential. We recommend to wire this into some kind of start up check. Please refer to the example app to see how we used it.

1.0.0 #

  • Initial Release

1.0.1 #

  • fix minor bugs

1.0.2 #

  • clean code

1.0.3+1 #

  • change file structure


picker_example #

Demonstrates how to use the picker plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  picker: ^1.0.3+1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:picker/picker.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 12, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
video_player 0.10.1+5