搜索分类、插件与代码仓

插件详情v1.0.0

flutter_camera

一个适用于 iOS 和 Android 的 Flutter 插件,允许访问设备摄像头并录制视频。

AndroidiOSWeb
近 30 天下载
83
喜欢数
25
Pub 分数
120

安装插件

flutter pub add flutter_camera

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Flutter Camera 是一个跨平台插件,适用于 Flutter,使开发者能够在 Android、iOS 和 Web 上访问设备摄像头并录制视频。它提供了一个简单的 API,用于拍摄照片、流式传输实时摄像头预览以及录制高质量视频。设计简洁且性能出色,支持常见的摄像头操作,如对焦、闪光灯控制和分辨率选择。非常适合需要实时摄像头集成的应用程序,例如照片分享、视频通话或增强现实功能。

适合场景

  • 视频录制
  • 图像捕获
  • 实时摄像头预览
  • 增强现实应用
  • 视频会议
  • 文档扫描

主要特点

  • 跨平台支持
  • 实时摄像头流
  • 视频录制
  • 图像捕获
  • 聚焦和闪光灯控制
  • 分辨率自定义

适合对象

  • 移动应用开发者
  • 实时摄像头应用
  • 媒体丰富的应用
  • Web 和移动混合项目
  • AR/VR 集成

使用建议

  • 需要 Android 和 iOS 的相机权限
  • 某些浏览器中的网络摄像头支持有限
  • 性能在低端设备上可能有所不同
  • Web 部署需要额外配置
  • 可能需要处理平台特定的边缘情况

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Camera

pub package

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 ).
  • Only 3 lines of code

Installation

First, add flutter_camera as a dependency in your pubspec.yaml file.

iOS

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.

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_camera/flutter_camera.dart';

class CameraPage extends StatefulWidget {
  const CameraPage({Key? key}) : super(key: key);

  @override
  _CameraPageState createState() => _CameraPageState();
}

class _CameraPageState extends State<CameraPage> {
  @override
  Widget build(BuildContext context) {
    return FlutterCamera(
      color: Colors.amber,
      onImageCaptured: (value) {
        final path = value.path;
        print("::::::::::::::::::::::::::::::::: $path");
        if (path.contains('.jpg')) {
          showDialog(
              context: context,
              builder: (context) {
                return AlertDialog(
                  content: Image.file(File(path)),
                );
              });
        }
      },
      onVideoRecorded: (value) {
        final path = value.path;
        print('::::::::::::::::::::::::;; dkdkkd $path');
        ///Show video preview .mp4
      },
    );
    // return Container();
  }
}

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。