Camera for Flutter
Camera capture and gallery picking
A live preview and video capture with a correct controller lifecycle, and gallery picking handled by the right plugin for each job.
What this feature covers
- Live preview: A camera preview with focus, flash and zoom.
- Capture: Photo and video capture.
- Gallery: Image picking for a form input, an avatar or a document scan.
- Permissions: Camera permissions treated as a state machine.
- Compression: Resize and compress before upload, with EXIF correction.
How Flutter Agent Kit implements it
The kit picks the right tool per job: the camera plugin for a live preview, video and in-app controls, and image_picker for a take-a-photo-or-choose-an-input row. The CameraController lives in the screen State and is never held by a provider or singleton, since it is bound to one platform view, and state stores paths, never image bytes, to avoid Android out-of-memory crashes.
Permissions map a CameraException code to a UI state instead of a boolean, so denied, deniedWithoutPrompt and restricted are handled differently. On web, shared code branches through a capability flag and renders the blob URL with Image.network, because dart:io does not exist there. Android, iOS and web are supported; desktop has no live preview.
Frequently asked questions
Should I use the camera plugin or image_picker?
Use the camera plugin when the feature needs a live preview, video, flash, zoom or tap-to-focus. Use image_picker when it is just a take a photo or choose from gallery input inside a form. Never mix the two for the same action in the same screen.
Why not keep the captured image bytes in state?
Bytes in state are the classic Android out-of-memory crash after a few captures. The kit stores the path or the XFile instead and loads the image from there, and it compresses and resizes before upload since a phone photo can be several megabytes.
Get Flutter Agent Kit
Flutter Agent Kit ships this as a ready feature skill, together with the AGENTS.md context layer and the rest of the skills. €99.99 one-time, lifetime updates, unlimited personal and commercial projects.
Browse all features included in Flutter Agent Kit.