Back to results for “Media”
Flutter › Camera & Media Handling in Flutter

What is the image_picker package, and how does it provide a simpler way to let users select an existing photo or take a new one, compared to directly using the lower level camera package?

Beginner

Answer

The image_picker package provides a much simpler, higher level interface specifically for the common task of letting a user either pick an existing image from their device's photo gallery or capture a brand new photo using the camera, handling the underlying native camera or gallery interface for you, and it does not offer the fine grained control of a fully custom live camera preview, but for many everyday app features, such as letting a user set a profile picture, this simpler approach requires far less code than manually integrating the full camera package.
final picker = ImagePicker();
final image = await picker.pickImage(source: ImageSource.gallery);
Real-world example A profile settings screen uses image_picker to let a user quickly select an existing photo from their gallery for their profile picture, avoiding the need to build an entirely custom camera preview interface just for this simple task.

Common follow-ups: When would you choose the full camera package over the simpler image_picker package?;How do you also let a user pick a video rather than just a still image using image_picker?