搜尋分類、套件與程式碼儲存庫

套件詳情v0.14.0

qr_code_dart_scan

一個使用 Dart 解碼器在 iOS 與 Android 上都能正常運作的二維碼掃描器。

AndroidiOS
近 30 天下載
1.4萬
喜歡數
67
Pub 分數
120

安裝套件

flutter pub add qr_code_dart_scan

套件介紹

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

一個適用於 Flutter 應用的跨平台 QR 碼掃描器,利用基於 Dart 的解碼器在 Android 和 iOS 上順暢運作。它能在不依賴原生相機 API 的情況下實時掃描,為在 Dart 中直接整合 QR 碼功能提供輕量且高效解決方案。此套件非常適合需要從 QR 碼快速提取資料的應用場景,例如票務、驗證或產品資訊檢索。設計以簡潔為宗旨,提供簡單的整合與可靠的解碼效能。

適用情境

  • 在移動應用中掃描二維碼
  • 數位票務驗證
  • 產品資訊查詢
  • 透過QR碼進行使用者驗證
  • 設備間快速資料傳輸

主要特色

  • 跨平台支援(iOS 與 Android)
  • Dart 原生解碼引擎
  • 輕巧且快速
  • 簡單 API 結合
  • 即時掃描功能

適合對象

  • 開發需要二維碼掃描功能的移動應用的開發者
  • 需要離線二維碼解碼的應用
  • 專案避免原生相機依賴

使用建議

  • 僅限二維碼(不包含條形碼)
  • 性能取決於設備攝像頭的品質
  • 可能需要相機權限
  • 無內建UI——需自訂實作

原始 README

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

pub package

QRCodeDartScan

A QR code scanner that works on both iOS and Android using dart decoder.

Scanning normal Qr code Scanning invert Qr code

APK DEMO

Features

  • Camera scan preview in a widget
  • Scan QRCode
  • Scan inverted QRCode

Supported platforms

This package is limited per camera pluggin support.

Platform Scan live Scan take picture
Android :white_check_mark: :white_check_mark:
IOS :white_check_mark: :white_check_mark:
WEB :white_check_mark:
Windows
MacOS
Linux

Supported Formats

  • QR_CODE
  • AZTEC
  • DATA_MATRIX
  • PDF_417
  • CODE_39
  • CODE_93
  • CODE_128
  • EAN_8
  • EAN_13
  • ITF

Installation

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

iOS

iOS 10.0 of higher is needed to use the camera plugin. If compiling for any version lower than 10.0 make sure to check the iOS version before using the camera plugin. For example, using the device_info plugin.

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

It's important to note that the MediaRecorder class is not working properly on emulators, as stated in the documentation: https://developer.android.com/reference/android/media/MediaRecorder. Specifically, when recording a video with sound enabled and trying to play it back, the duration won't be correct and you will only see the first frame.

dependency_overrides:
  camera_android_camerax: 0.6.14
Using

    return Scaffold(
      body: QRCodeDartScanView(
        onCameraError: (String error) {
          debugPrint('Error: $error');
        },
        // cropRect: CropRect(left: 0, top: 0, width: 100, height: 100), // You can crop the image to improve accuracy by specifying a rectangle region. ( default = null)
        // imageDecodeOrientation: ImageDecodeOrientation.original, // you can force how the image orientation will be decoded (default = original)
        typeScan: TypeScan.live, // if TypeScan.takePicture will try decode when click to take a picture(default TypeScan.live)
        // intervalScan: const Duration(seconds:1)
        // onResultInterceptor: (old,new){
        //  do any rule to controll onCapture.
        // }
        // takePictureButtonBuilder: (context,controller,isLoading){ // if typeScan == TypeScan.takePicture you can customize the button.
        //    if(loading) return CircularProgressIndicator();
        //    return ElevatedButton(
        //       onPressed:controller.takePictureAndDecode,
        //       child:Text('Take a picture'),
        //    );
        // }
        // resolutionPreset: = QrCodeDartScanResolutionPreset.high,
        // formats: [ // You can restrict specific formats.
        //  BarcodeFormat.qrCode,
        //  BarcodeFormat.aztec,
        //  BarcodeFormat.dataMatrix,
        //  BarcodeFormat.pdf417,
        //  BarcodeFormat.code39,
        //  BarcodeFormat.code93,
        //  BarcodeFormat.code128,
        //  BarcodeFormat.ean8,
        //  BarcodeFormat.ean13,
        // ],
        // croppingStrategy: CroppingStrategy.cropCenterSquare(
        //   squareSizeFactor: 0.7,
        // ),
        onCapture: (ScanResult result) {
          // do anything with result
          // result.text      -> String
          // result.format    -> BarcodeFormat
          // result.corners   -> List<Point<double>>, in camera preview
          //                     coordinates. Use `result.corners.toOffsets`
          //                     to paint them.
          // result.rawBytes  -> Uint8List?
          // result.timestamp -> DateTime
        },
      ),
    );
    

ATTENTION

Always use this package in portrait mode.

There is a bug in the camera plugin that sometimes the image is rotated 90 degrees, to avoid this problem, you can use the imageDecodeOrientation parameter to force the image to be decoded in the correct orientation.

For example, if you are reading an ITF code, you can force the image to be decoded in landscape orientation.

imageDecodeOrientation: ImageDecodeOrientation.landscape,

if you want to force the image to be decoded in portrait orientation, you can use the following code:

imageDecodeOrientation: ImageDecodeOrientation.portrait,
Camera performance

The decoder process is done in dart code. So, in flutter debug mode, you will not have a good performance. But in release mode, the performance is very better.

所屬分類

依賴

依賴清單 6 項

原始碼儲存庫

使用此套件的專案