搜尋套件、儲存庫與 APP 分類

套件詳情v0.2.4

zxing2

一個以 Dart 實作的多格式一維/二維條碼影像處理程式庫。這是 Android 程式庫的移植版本。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
33.2萬
喜歡數
76
Pub 分數
160

安裝套件

flutter pub add zxing2

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

zxing2 是 ZXing 條碼處理庫的 Dart 實作,支援多格式的一維與二維條碼掃描與產生。它是廣受歡迎的 Android ZXing 庫的移植版本,讓 Flutter 應用能夠實現跨平台的條碼功能。此套件可在 Android、iOS、Web、macOS、Windows 與 Linux 上運作,非常適合需要在各種裝置上可靠讀取與寫入條碼的應用程式。

適用情境

  • 在移動應用中掃描二維碼
  • 產生條碼以進行庫存追蹤
  • 在零售應用中讀取產品代碼
  • 在Web應用程式中整合條碼輸入
  • 支援條碼文件掃描

主要特色

  • 跨平台條碼支援
  • 條形碼檢測的高精度
  • 支援多種格式(QR、Data Matrix、PDF417 等)
  • 輕量且快速處理
  • 與 Flutter UI 的輕鬆整合

適合對象

  • 需要條碼掃描的移動和網路應用
  • 電子商務和物流應用
  • 庫存和資產管理工具
  • 需要透過條碼進行安全資料編碼的應用程式
  • 尋求在多個平台上實現原生效能的開發者

使用建議

  • 在移動平台需要相機權限
  • 可能需要針對低階設備進行優化
  • 僅限基於圖像的條形碼處理
  • 沒有用於掃描的內建UI元件
  • 性能取決於影像品質和照明條件

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

zxing-dart

ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library.
This package is a pure Dart port of the original Java library.

For now, it only supports QR-Code (encoding and decoding). New format can easily be added if this port proves useful.

pub package Build Status codecov

Buy Me A Coffee

Getting started

QR Code
Decoding

The QRCodeReader class takes a list of bytes and returns the decoded barcode.

import 'dart:io';
import 'package:image/image.dart' as img;
import 'package:zxing2/qrcode.dart';

void main() {
  var image = img.decodePng(File('tool/example.png').readAsBytesSync())!;

  LuminanceSource source = RGBLuminanceSource(
      image.width,
      image.height,
      image
          .convert(numChannels: 4)
          .getBytes(order: img.ChannelOrder.abgr)
          .buffer
          .asInt32List());
  var bitmap = BinaryBitmap(GlobalHistogramBinarizer(source));

  var reader = QRCodeReader();
  var result = reader.decode(bitmap);
  print(result.text);
}
Encoding

The QRCodeReader class takes a list of bytes and returns the decoded barcode.

import 'dart:io';
import 'package:image/image.dart' as img;
import 'package:zxing2/qrcode.dart';

void main() {
  var qrcode = Encoder.encode('ABCDEF', ErrorCorrectionLevel.h);
  var matrix = qrcode.matrix!;
  var scale = 4;

  var image = img.Image(
      width: matrix.width * scale,
      height: matrix.height * scale,
      numChannels: 4);
  for (var x = 0; x < matrix.width; x++) {
    for (var y = 0; y < matrix.height; y++) {
      if (matrix.get(x, y) == 1) {
        img.fillRect(image,
            x1: x * scale,
            y1: y * scale,
            x2: x * scale + scale,
            y2: y * scale + scale,
            color: img.ColorRgba8(0, 0, 0, 0xFF));
      }
    }
  }
  var pngBytes = img.encodePng(image);
  File('tool/examples/encoded.png').writeAsBytes(pngBytes);
}

Flutter

The example folder contains a full example that uses the official camera plugin connected to this package to decode barcode from the bytes stream.

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案