Use image_picker when the user just needs to pick a photo or take one: await ImagePicker().pickImage(source: ImageSource.camera) returns the file, or null if they cancel. Use the camera package only when you must show a live camera preview inside your own screen, for example a scanner or a custom shutter.

This guide is for Flutter developers adding photos. It uses image_picker 1.2.4 and camera 0.12.1, both published by flutter.dev (October 2026). The running example is a receipt-saving app.

In short:

  • image_picker opens the phone's own picker and camera, so it needs no preview code.
  • iOS stops the app if Info.plist lacks the usage-description text.
  • Android may close your app mid-photo. retrieveLostData() recovers the image.
  • The camera package supports Android, iOS and web only.

image_picker covers most apps

The package works on Android, iOS, web, Windows, Linux and macOS, according to its pub.dev page. Three calls cover the common cases:

final picker = ImagePicker();
            final XFile? fromGallery = await picker.pickImage(source: ImageSource.gallery);
            final XFile? fromCamera = await picker.pickImage(
              source: ImageSource.camera, maxWidth: 1600, imageQuality: 80);
            final List<XFile> many = await picker.pickMultiImage();
            

maxWidth and imageQuality (0 to 100) resize and compress before you get the file. A receipt photo at 1600 pixels wide is readable and much smaller to upload. Read the bytes with await file.readAsBytes(), which works on web as well as mobile.

iOS needs three text keys

Apple blocks the picker without a reason string. Add to ios/Runner/Info.plist:

  1. NSPhotoLibraryUsageDescription, why you need the photo library.
  2. NSCameraUsageDescription, why you need the camera.
  3. NSMicrophoneUsageDescription, only if you record video.

The package page says the photo-library key is required by App Store policy even if you never request full metadata. Write real sentences, such as "Take a photo of your receipt".

Android can kill your app mid-photo

On Android, the system may close your app while the camera is open if memory is low. When the user returns, your screen is rebuilt and the photo seems lost.

The package offers retrieveLostData() to recover it, and its page explains the setup. Call it at startup on any screen that takes photos. On Android 13 and above the package uses the system Photo Picker.

Desktop and web differ

On Windows, macOS and Linux, ImageSource.camera is not supported by default, because there is no system camera screen. You must supply a camera delegate. Selection options such as max width are also not supported on desktop. If your app targets the web, test the camera path on your target browsers and devices: image_picker uses a file input with a capture hint, so camera capture is not guaranteed.

The camera package is for custom screens

Choose camera when you need CameraPreview in your own layout. The flow, from the Flutter cookbook, is:

  1. Call availableCameras() after WidgetsFlutterBinding.ensureInitialized().
  2. Create a CameraController with a camera and a ResolutionPreset.
  3. Await controller.initialize(), then show CameraPreview(controller).
  4. Call controller.takePicture() to get an XFile.
  5. Call controller.dispose() in your widget's dispose().

Forgetting step 5 leaves the camera locked. The package lists Android, iOS (13.0 and up) and web only.

Where the photo goes next

A picked file is temporary. To keep it, upload it to Firebase Storage and save the link in your database, or write it to the app's documents folder with path_provider.

Generated apps add Storage for photo uploads

GrowApps builds Flutter apps from a chat. When an app needs file uploads, its builder adds Firebase Storage and sends files to the app's own storage folder, with a 50 MB cap per file. Describe the photo flow you want in the chat. Start at growapps.ai.

Take a photo and deny permission once

Add flutter pub add image_picker, paste the fromCamera line behind a button, and add the three iOS keys. Run on a real phone, deny camera permission once, and confirm your screen handles the PlatformException; separately, cancel the picker and confirm it handles a null result.

Sources and further reading