搜索插件、代码仓与 APP 分类

插件详情v0.1.1

camerakit

Flutter camera kit 使用原生 Android 和 iOS API 来拍照和扫描条形码,并支持可控闪光灯。

AndroidiOS
近 30 天下载
208
喜欢数
33
Pub 分数
125

安装插件

flutter pub add camerakit

插件介绍

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

CameraKit 是一个 Flutter 插件,利用原生 Android 和 iOS 相机 API 实现高性能的图片捕捉和条形码扫描。它为开发者提供了对相机功能的精细控制,包括可调节的闪光灯设置,以实现最佳照明条件。设计上支持无缝集成,可在两个平台以最少的配置运行。该包非常适合需要可靠相机功能的应用程序,例如文档扫描、二维码读取器或照片捕捉工具。

适合场景

  • 零售应用中的条形码扫描
  • 数字表单的文档捕获
  • 移动库存系统中的照片捕获
  • 二维码生成和读取
  • 实时图像处理工作流

主要特点

  • Android 和 iOS 的原生相机访问
  • 闪光灯控制,实现更佳照明
  • 条形码和二维码扫描
  • 高分辨率图像捕获
  • 跨平台兼容性

适合对象

  • 需要摄像头集成的移动应用
  • 需要条形码扫描的应用程序
  • 开发库存或文档工具的开发者
  • 使用实时摄像头画面的项目
  • 针对 Android 和 iOS 的 Flutter 应用

使用建议

  • 需要在应用清单中授予相机权限
  • 可能需要额外设置以进行条形码扫描
  • 仅限相机特定任务
  • 依赖原生 SDK 才能实现完整功能
  • 不适用于视频录制或高级相机效果

原始 README

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

Use Prerelease version to support nullsafety.

Flutter Camera Kit

Flutter camera kit uses native android and ios APIs for taking picture and scanning barcode with controlable flash.This plugin uses Camera2 API in android and AVFoundation in iOS for taking picture and MLFirebase library for scanning barcode.

Main features:

  • Easy implementation with controller
  • Automatic permission handling (no need for 3rd-party libraries)
  • Automatic camera resource handling for battery usage and avoid any conflict with another camera based applications.(you can also manage manually pause and resume camera)
  • fill and fit mode for camera preview frame.
  • Optimize memory usage in taking picture
  • auto, on and off flash mode while taking picture and scan barcode.

Installation

iOS

Add io.flutter.embedded_views_preview in info.plist with value YES. Add Privacy - Camera Usage Description in info.plist.

Usage

For use plugin, You shoude an instance of CameraKitController then initial CameraKitView passing CameraKitController instance to it.

   cameraKitController = CameraKitController();
    cameraKitView = CameraKitView(
      cameraKitController: cameraKitController,
      hasBarcodeReader: true,
      barcodeFormat: BarcodeFormats.FORMAT_ALL_FORMATS
      scaleType: ScaleTypeMode.fill,
      previewFlashMode: CameraFlashMode.auto,
      androidCameraMode: AndroidCameraMode.API_X,
      cameraSelector: CameraSelector.back
      onPermissionDenied: () {
          print("Camera permission is denied.");
          //ToDo on permission denied by user
      },
      onBarcodeRead: (code) {
        print("Barcode is read: " + code);
        //ToDo on barcode read
      },
    );

Cunstructor parameters

hasBarcodeReader: True means scan barcode mode and false means take picture mode

barcodeFormat: Set barcode format from available values, default value is FORMAT_ALL_FORMATS.

scaleType: There are 2 modes ScaleTypeMode.fill and ScaleTypeMode.fit for this parameter. If you want camera preview fill your widget area, use fill mode. In this mode, camera preview may be croped for filling widget area. If you want camera preview to show entire lens preview, use fit mode. In this mode, camera preview may be shows blank areas.

previewFlashMode: This parameter accepts 3 values, CameraFlashMode.auto, CameraFlashMode.on and CameraFlashMode.off. For changing value after initial use changeFlashMode method in controller.

androidCameraMode: This parameter has been replaced with useCamera2API. This parameter accepts 3 values, API_X, API_1, API_2. Default value is API_X. Some feature is available in each value. API_1 features: Taking picture API_2 features: Taking picture, Scaning barcode (Taking picture with flash has some issues, Auto flash in barcode scanning mode works in some phones.) API_X features: Taking picture, Scaning barcode (Auto flash in barcode scanning mode doesn't work.)

cameraSelector: Set front and back camera with this parameter. This parameter accepts 3 values, back and front

onPermissionDenied: After android and iOS user deny run time permission, this method is called.

onBarcodeRead: In barcodeReader mode, while camera preview detect barcodes, This method is called.

Controller methods

Take Picture You can take picture with this method. Unlike API_2, in API_X, you can take picture in scaning barcode mode. You can pass your custom path for save image. You can pass nothing and the image will be saved in default path.

  String path = await cameraKitController.takePicture({Your custom path});

Change Flash Mode For changing flash mode, don't change cunstructor parameter. Use changeFlashMode method in controller. Pass CameraFlashMode enum to this method.

    cameraKitController.changeFlashMode(CameraFlashMode.on);

Pause and Resume camera This plugin automatically manage pause and resume camera based on android, iOS life cycle and widget visibility, also you can call with your controller when ever you need.

    cameraKitController.pauseCamera();
    cameraKitController.resumeCamera();

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。