Flutter Camera 是一个跨平台插件,适用于 Flutter,使开发者能够在 Android、iOS 和 Web 上访问设备摄像头并录制视频。它提供了一个简单的 API,用于拍摄照片、流式传输实时摄像头预览以及录制高质量视频。设计简洁且性能出色,支持常见的摄像头操作,如对焦、闪光灯控制和分辨率选择。非常适合需要实时摄像头集成的应用程序,例如照片分享、视频通话或增强现实功能。
适合场景
视频录制
图像捕获
实时摄像头预览
增强现实应用
视频会议
文档扫描
主要特点
跨平台支持
实时摄像头流
视频录制
图像捕获
聚焦和闪光灯控制
分辨率自定义
适合对象
移动应用开发者
实时摄像头应用
媒体丰富的应用
Web 和移动混合项目
AR/VR 集成
使用建议
需要 Android 和 iOS 的相机权限
某些浏览器中的网络摄像头支持有限
性能在低端设备上可能有所不同
Web 部署需要额外配置
可能需要处理平台特定的边缘情况
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Flutter Camera
A Flutter plugin for iOS and Android allowing access to the device cameras and recording of videos.
Note: This plugin is still under development, and some APIs might not be available yet. We are working on a refactor which can be followed here: issue
This package fully depends on flutter camera plugin to provide access to camera.
It only supports Android and IOS for now
Features
Display live camera preview in a widget.
Snapshots can be captured and path is returned.
Device flash light support.
Record video from camera.
Add access to the image stream from Dart.
Live camera flip ( switch between rear & front camera with a click ).
The camera plugin functionality works on iOS 10.0 or higher. If compiling for any version lower than 10.0,
make sure to programmatically check the version of iOS running on the device before using any camera plugin features.
The device_info_plus plugin, for example, can be used to check the iOS version.
Add two rows to the ios/Runner/Info.plist:
one with the key Privacy - Camera Usage Description and a usage description.
and one with the key Privacy - Microphone Usage Description and a usage description.
Or in text format add the key:
<key>NSCameraUsageDescription</key><string>Can I use the camera please?</string><key>NSMicrophoneUsageDescription</key><string>Can I use the mic please?</string>
Android
Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.
minSdkVersion 21
Example
Here is a small example flutter app displaying a full screen camera preview with video recording.