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

qr_code_scanner_plus 封面
套件詳情v2.4.1

qr_code_scanner_plus

可嵌入 Flutter 的 QR 碼掃描器。Android 使用 zxing,iOS 使用 AVFoundation。

AndroidiOSWeb
近 30 天下載
9.9萬
喜歡數
131
Pub 分數
160

安裝套件

flutter pub add qr_code_scanner_plus

套件介紹

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

一個用於在應用程式中嵌入二維碼掃描功能的 Flutter 套件,利用原生庫:Android 上的 zxing 與 iOS 上的 AVFoundation。支援跨 Android、iOS 和 Web 平台的即時掃描,並實現順暢整合。專為尋求可靠、高效能二維碼掃描且無需複雜設定的開發者設計。此套件由 vespr.xyz 維護,並可透過 pub.dev 取得。

適用情境

  • 應用內QR碼掃描支付
  • 透過QR碼進行使用者驗證
  • 產品資訊檢索
  • 活動門票驗證
  • 設備間的數據共享
  • 庫存管理

主要特色

  • 原生效能,適用於 Android 和 iOS
  • 跨平台支援(Android、iOS、Web)
  • 與 Flutter 小部件的簡單整合
  • 即時掃描功能
  • 輕便高效
  • 開源且公開倉儲

適合對象

  • 行動應用開發者
  • 支付與金融科技應用
  • 活動和票務平台
  • 零售和庫存系統
  • 需要安全數據交換的應用程式

使用建議

  • Web 支援可能具有有限的攝影機存取權限
  • 需要行動裝置上的相機權限
  • 性能取決於設備硬體
  • 可能需要額外的設定才能進行網路部署
  • 掃描介面的自訂選項有限

原始 README

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

pub package

⚠️ If you are starting a new project, or your project requires new features or long-term stability, use an actively maintained alternative such as mobile_scanner.


⚠️ Maintenance-only fork (no new features)

This package is a maintenance-only fork of the original qr_code_scanner package.

Its sole purpose is to keep existing projects compiling and running on newer versions of Flutter, the Android Gradle Plugin, and related tooling after the upstream package became unmaintained. It exists to allow existing users to postpone migration, not to provide an actively developed QR scanning solution.

New feature PRs will be rejected.
This includes (but is not limited to):

  • New functionality
  • Feature extensions
  • API changes or expansions
  • Behavior changes beyond minimal fixes required for compatibility

If you need additional functionality, this package is not the right choice.


Scope and limitations

  • I maintain only the Flutter-facing code in this repository.
  • The underlying native scanning is handled by:
    • Android: zxing
    • iOS: Native AVFoundation (Swift Package Manager and CocoaPods supported)

The original qr_code_scanner package used MTBBarcodeScanner on iOS, which has been archived and unmaintained since 2021. This fork replaced it with a native AVFoundation implementation to enable Swift Package Manager support and remove the only third-party iOS dependency.

The Android native library (zxing) is outdated and unmaintained. There are known issues and limitations in that native package that will not be fixed here.

As a result:

  • Native-level bugs should be expected.
  • This package is not a good foundation for adding or extending features.
  • Only minimal fixes required to keep the package usable on current Flutter toolchains will be considered.

Projects that require new functionality, reliability, or long-term maintenance of both Flutter and native code should migrate to a fully maintained alternative such as mobile_scanner.


QR Code Scanner Plus

A QR code scanner for iOS, Android, and Web that embeds platform views in Flutter.

This description is retained for historical context only and does not imply ongoing feature development.


Screenshots

Android

iOS

Get Scanned QR Code

When a QR code is recognized, the text identified will be set in 'result' of type Barcode, which contains the output text as property 'code' of type String and scanned code type as property 'format' which is an enum BarcodeFormat, defined in the library.

class _QRViewExampleState extends State<QRViewExample> {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  Barcode? result;
  QRViewController? controller;

  // In order to get hot reload to work we need to pause the camera if the platform
  // is android, or resume the camera if the platform is iOS.
  @override
  void reassemble() {
    super.reassemble();
    if (Platform.isAndroid) {
      controller!.pauseCamera();
    } else if (Platform.isIOS) {
      controller!.resumeCamera();
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Expanded(
            flex: 5,
            child: QRView(
              key: qrKey,
              onQRViewCreated: _onQRViewCreated,
            ),
          ),
          Expanded(
            flex: 1,
            child: Center(
              child: (result != null)
                  ? Text(
                      'Barcode Type: ${describeEnum(result!.format)}   Data: ${result!.code}')
                  : Text('Scan a code'),
            ),
          )
        ],
      ),
    );
  }

  void _onQRViewCreated(QRViewController controller) {
    this.controller = controller;
    controller.scannedDataStream.listen((scanData) {
      setState(() {
        result = scanData;
      });
    });
  }
}

Android Integration

In order to use this plugin, please make sure to add the Camera permissions in android/app/src/main/AndroidManifest.xml

    <uses-permission android:name="android.permission.CAMERA" />

iOS Integration

In order to use this plugin, add the following to your Info.plist file:

<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes</string>
UIScene lifecycle

The iOS plugin supports both the UIScene lifecycle and the legacy application lifecycle. No plugin-specific SceneDelegate or camera lifecycle changes are required.

The host app must still adopt UIScene; updating this package alone does not migrate your app. Follow Flutter's UIScene migration guide to configure UIApplicationSceneManifest in Info.plist and register plugins in didInitializeImplicitFlutterEngine using engineBridge.pluginRegistry. The example AppDelegate and example Info.plist already use this setup.

Web Integration

Add this to web/index.html:

<script src="https://cdn.jsdelivr.net/npm/jsqr@1.3.1/dist/jsQR.min.js"></script>

Please note: on web, only QR codes are supported. Other barcodes and 2D codes cannot be scanned.

Web support is in very early stage. Features such as flash, pause or resume are not implemented. Moreover, the camera preview does not respect the surrounding constraints. This is not at last due to Flutter's early state of platform views on web.

Flip Camera (Back/Front)

The default camera is the back camera.

await controller.flipCamera();

Flash (Off/On)

By default, flash is OFF.

await controller.toggleFlash();

Resume/Pause

Pause camera stream and scanner.

await controller.pauseCamera();

Resume camera stream and scanner.

await controller.resumeCamera();

Credits

  • Android: https://github.com/zxing/zxing
  • Original qr_code_scanner contributors

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案