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

插件详情v3.0.15

flutter_barcode_scanner_plus

一个支持 Android 和 iOS 上条形码扫描的插件。支持条形码、二维码等。

AndroidiOS
近 30 天下载
1.1万
喜欢数
20
Pub 分数
160

安装插件

flutter pub add flutter_barcode_scanner_plus

插件介绍

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

一个 Flutter 插件,可在 Android 和 iOS 设备上实现条形码和二维码扫描。它提供了一个简单可靠的接口,用于捕获和解码各种类型的条形码,包括二维码、EAN、UPC 等。通过原生集成构建,确保跨平台的快速准确扫描性能。该包非常适合需要通过视觉码快速输入数据的应用程序,例如库存系统、票务或产品查询工具。

适合场景

  • 库存管理
  • 票务扫描
  • 产品信息查询
  • 通过二维码进行用户身份验证
  • 移动支付

主要特点

  • 支持多种条形码格式
  • 跨平台兼容性(Android 和 iOS)
  • 高速扫描
  • 简单 API 集成
  • 实时预览支持

适合对象

  • 零售应用
  • 事件票务系统
  • 物流和仓储
  • 移动支付解决方案
  • 数字身份验证

使用建议

  • 需要相机权限
  • 可能需要背景执行设置
  • 性能因设备硬件而异
  • 仅限移动平台
  • iOS相机访问的额外配置

原始 README

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

flutter_barcode_scanner_plus

A plugin for Flutter apps that adds barcode scanning support on both Android and iOS.

pub package

Demo gif

Try example

Just clone or download the repository, open the project in Android Studio/ VS Code, open pubspec.yaml and click on Packages get. Connect device and hit run. To run on iPhone you need to run from Xcode first time and just make pod install in example/ios then run from Xcode.

Getting Started

Follow the steps for Android and iOS

PLEASE FOLLOW iOS STEPS CAREFULLY

Android

:zap: Don't worry, you don't need to do anything.

iOS - Requires Swift support

Deployment target : 12

1. Fresh start:
  1. Create a new flutter project. Please check for Include swift support for iOS code.
  2. After creating new flutter project open /ios project in Xcode and set minimum deployment target to 12 and set Swift version to 5.
  3. After setting up the deployment target and swift version, close the Xcode then run pod install in /ios in flutter project.

You have done with basic configuration now proceed to section How to use.

2. Adding to existing flutter app:
If your existing ios code is Swift then you just need to do following.
  1. Set minimum deployment target to 12 and set Swift version to 5.
  2. Close the Xcode and run pod install in /ios in flutter project.
  3. Now proceed to section How to use.
If your existing ios code is Objective-C then you need to do following.
  1. Create a new flutter project with same name at different location (Don't forget to check Include swift support for iOS code while creating)
  2. Just copy newly created /ios folder from project and replace with existing /ios.
  3. Open ios project in Xcode and set minimum deployment target to 12 and set Swift version to 5.
  4. Run pod install in /ios

Note: If you did any changes in ios part before, you might need to make these configuration again

How to use ?

To use on iOS, you will need to add the camera usage description. To do that open the Xcode and add camera usage description in Info.plist.

<key>NSCameraUsageDescription</key>
<string>Camera permission is required for barcode scanning.</string>

After making the changes in Android ans iOS add flutter_barcode_scanner to pubspec.yaml

dependencies:
  ...
  flutter_barcode_scanner_plus: ^3.0.15
One time scan
  1. You need to import the package first.
import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
  1. Then use the scanBarcode method to access barcode scanning.
String barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
                                                    COLOR_CODE,
                                                    CANCEL_BUTTON_TEXT,
                                                    isShowFlashIcon,
                                                    scanMode);

Here in scanBarcode,

COLOR_CODE is hex-color which is the color of line in barcode overlay you can pass color of your choice,

CANCEL_BUTTON_TEXT is a text of cancel button on screen you can pass text of your choice and language,

isShowFlashIcon is bool value used to show or hide the flash icon,

scanMode is a enum in which user can pass any of { QR, BARCODE, DEFAULT }, if nothing is passed it will consider a default value which will be QR. It shows the graphics overlay like for barcode and QR.

NOTE: Currently, scanMode is just to show the graphics overlay for barcode and QR. Any of this mode selected will scan both QR and barcode.

Continuous scan
  • If you need to scan barcodes continuously without closing camera use FlutterBarcodeScanner.getBarcodeStreamReceiver params will be same like FlutterBarcodeScanner.scanBarcode e.g.
FlutterBarcodeScanner.getBarcodeStreamReceiver("#ff6666", "Cancel", false, ScanMode.DEFAULT)
         .listen((barcode) {
         /// barcode to be used
         });
Contribution:

would :heart: to see any contribution, give :star: if you like

Contact:

E-mail: sarangthemamarjit123@gmail.com

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。