camera
0.12.2, released 3 weeks ago by flutter.dev
Flutter plugin to preview, capture photos/video and stream camera images.
WASM-ready
What it does
Provides a widget for live camera preview, methods to take pictures and record video, and an image stream API. Works on Android, iOS and Web.
AI-written summary of version 0.12.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need direct access to device cameras for photos, video or real‑time image processing
- You require a cross‑platform solution that supports Android, iOS and Web
Skip it when
- You only need simple image picking without live preview
- You prefer a higher‑level abstraction like barcode scanning only
Strengths
- Full‑screen preview widget
- Supports zero‑shutter‑lag and video stabilization
- Image stream for custom processing
- Works on three major platforms
Weaknesses
- Requires native permission handling and lifecycle management
- No built‑in UI for scanning or advanced effects
- Plugin size adds native binaries
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 5
Add camera and microphone usage descriptions to iOS Info.plist; ensure Android minSdk 24; handle app lifecycle and permission errors manually.
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
late List<CameraDescription> _cameras;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
_cameras = await availableCameras();
runApp(const CameraApp());
}
class CameraApp extends StatefulWidget {
const CameraApp({super.key});
@override
State<CameraApp> createState() => _CameraAppState();
}
class _CameraAppState extends State<CameraApp> {
late CameraController _controller;
@override
void initState() {
super.initState();
_controller = CameraController(_cameras[0], ResolutionPreset.max);
_controller.initialize().then((_) => setState(() {}));
}
@override
void dispose() { _controller.dispose(); super.dispose(); }
@override
Widget build(BuildContext context) {
if (!_controller.value.isInitialized) return const SizedBox();
return MaterialApp(home: CameraPreview(_controller));
}
}
Alternatives
Packages that do the same job and could replace camera.
- mobile_scanner
If you only need QR/barcode scanning with a simpler API and less lifecycle handling
95Compare
Works with
Packages commonly used together with camera: ones it builds on, ones built on it, and its own family.
- flutter_plugin_android_lifecyclecamera depends on itFlutter plugin for accessing Android Lifecycle within other plugins.
- camera_android_cameraxcamera depends on itAndroid camera implementation using CameraX library
- camera_avfoundationcamera depends on itiOS implementation of the Flutter camera plugin providing preview, photo, and video capture.
- camera_webcamera depends on itWeb platform implementation for the Flutter camera plugin.
- local_auth_androidSame familyAndroid implementation of the local_auth plugin for biometric authentication.
- google_maps_flutter_androidSame familyAndroid implementation of the google_maps_flutter plugin.
- camera_androidSame familyAndroid implementation of the camera plugin using the Camera2 library.
- image_picker_androidSame familyAndroid implementation of the image_picker plugin for selecting photos and videos.