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

flutter_doc_scanner 封面
插件详情v0.0.21

flutter_doc_scanner

一个用于在 Android 和 iOS 上使用 ML Kit 文档扫描 API 和 VisionKit 进行文档扫描的 Flutter 插件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2.7万
喜欢数
166
Pub 分数
140

安装插件

flutter pub add flutter_doc_scanner

插件介绍

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

一个 Flutter 插件,通过利用 Google 的 ML Kit 文档扫描 API 和 Apple 的 VisionKit,在 Android 和 iOS 上实现文档扫描。它提供了一种无缝的方式,从图像中捕获并检测文档边缘,自动裁剪和增强扫描的文档。该插件支持 Web、macOS、Windows 和 Linux 等多个平台,非常适合需要文档数字化的跨平台应用。设计时注重集成简便性,无需深入了解原生代码即可轻松添加智能文档扫描功能。

适合场景

  • 移动应用中的文档数字化
  • 自动发票和收据扫描
  • 带有身份验证的入职工作流程
  • 从扫描文档生成PDF
  • 手机银行和表单处理

主要特点

  • 使用 ML Kit 和 VisionKit 进行精确检测
  • 跨平台支持所有主要操作系统
  • 用于图像捕获和处理的简单 API
  • 自动边缘检测和裁剪
  • 支持 Android 和 iOS,具有原生性能

适合对象

  • 开发文档密集型应用的开发者
  • 初创企业需要快速入职
  • 需要OCR就绪扫描的应用程序
  • 跨平台团队使用 Flutter
  • 企业自动化文件处理

使用建议

  • 需要移动设备上的相机权限
  • 性能在旧设备上可能有所不同
  • Web 支持取决于浏览器功能
  • 扫描UI的自定义选项有限
  • 依赖外部 SDK(ML Kit、VisionKit)

原始 README

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

flutter_doc_scanner

A Flutter plugin for document scanning on Android, iOS, and Web using ML Kit Document Scanner API and VisionKit.

pub package

Example

Check out the example directory for a sample Flutter app using flutter_doc_scanner.

Document Scanner Demo

Screenshots

Screenshot 1 Screenshot 2 Screenshot 3
Screenshot 4 Screenshot 5 Screenshot 6

Features

  • High-quality and consistent user interface for digitizing physical documents.
  • Accurate document detection with precise corner and edge detection for optimal scanning results.
  • Flexible functionality allows users to crop scanned documents, apply filters, remove fingers, remove stains and other blemishes.
  • On-device processing helps preserve privacy.
  • Support for sending digitized files in PDF and JPEG formats back to your app.
  • Ability to set a scan page limit.
  • Support for image(png,jpeg) format and PDF has been added through various methods.
  • Fast single-picture scanning mode via useAutomaticSinglePictureProcessing for quick one-document captures.

Installation

To use this plugin, add flutter_doc_scanner as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  flutter_doc_scanner: ^0.0.21

Got it! Here's a more detailed explanation:

Usage

Use the following function for document scanning on Android and iOS:

  Future<void> scanDocument() async {
  //by default way they fetch pdf for android and png for iOS
  dynamic scannedDocuments;
  try {
    scannedDocuments = await FlutterDocScanner().getScanDocuments(page: 3) ??
        'Unknown platform documents';
  } on PlatformException {
    scannedDocuments = 'Failed to get scanned documents.';
  }
  print(scannedDocuments.toString());
}

Note-: If you want to obtain only a PDF scanned document, call getScannedDocumentAsPdf(). Similarly, if you want to get a scanned document in image format, use getScannedDocumentAsImages().

Android result payloads
  • getScanDocuments / getScannedDocumentAsPdf: returns a map with pdfUri and pageCount.
  • getScannedDocumentAsImages / getScanDocumentsUri: returns a map with images (list of page URIs) and count (also exposed via legacy Uri / Count keys for backwards compatibility).

Project Setup

Follow the steps below to set up your Flutter project on Android, iOS, and Web.

Android
Minimum Version Configuration

Ensure you meet the minimum version requirements to run the application on Android devices. In the android/app/build.gradle file, verify that minSdkVersion is at least 21. This setting specifies the minimum Android API level required to run your app, ensuring compatibility with a wide range of Android devices.

android {
    ...
    defaultConfig {
        ...
        minSdkVersion 21
        ...
    }
    ...
}
iOS
Minimum Version Configuration

Ensure you meet the minimum version requirements to run the application on iOS devices. In the ios/Podfile file, make sure the iOS platform version is at least 13.0. This setting specifies the minimum iOS version required to run your app, ensuring compatibility with a wide range of iOS devices.

platform :ios, '13.0'
Permission Configuration
  1. Add a String property to the app's Info.plist file with the key NSCameraUsageDescription and the value as the description for why your app needs camera access. This step is required by Apple to explain to users why the app needs access to the camera, and it's crucial for App Store approval.
  <key>NSCameraUsageDescription</key>
  <string>Camera Permission Description</string>
  1. The permission_handler dependency used by flutter_doc_scanner uses macros to control whether a permission is enabled. To enable camera permission, add the following to your Podfile file. This step ensures that your app can request and handle camera permissions on iOS devices:
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      ... # Here are some configurations automatically generated by flutter

      # Start of the permission_handler configuration
      target.build_configurations.each do |config|

        # You can enable the permissions needed here. For example, to enable camera
        # permission, just remove the `#` character in front so it looks like this:
        #
        # ## dart: PermissionGroup.camera
        # 'PERMISSION_CAMERA=1'
        #
        #  Preprocessor definitions can be found at: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
          '$(inherited)',

          ## dart: PermissionGroup.camera
          'PERMISSION_CAMERA=1',
        ]

      end
      # End of the permission_handler configuration
    end
  end
Web

Currently, we have removed web support for this library. For document scanning on the web, you can use the following library: flutter_doc_scanner_web.

Issues and Feedback

Please file issues to send feedback or report a bug. Thank you!

License

The MIT License (MIT) Copyright (c) 2024 Shirsh Shukla

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

所属分类

依赖

依赖清单 1 项

  • plugin_platform_interface^2.0.2

源码仓库

使用此插件的项目

暂无相关数据。