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

套件詳情v1.0.4

qrcode

一個用於掃描二維碼的 Flutter 插件。在 iOS 上使用 AVCaptureSession,在 Android 上使用 zxing。

近 30 天下載
40
喜歡數
37
Pub 分數
40

安裝套件

flutter pub add qrcode

套件介紹

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

qrcode 包是一個專為 iOS 和 Android 平台設計的 Flutter 插件,用於掃描二維碼。在 iOS 上,它利用 AVCaptureSession 實現高效的條碼檢測;在 Android 上,則使用 ZXing 庫以確保可靠的掃描性能。這一輕量級解決方案使開發者能夠以最少的設定將二維碼掃描功能整合到其應用中。它支援即時掃描,並提供對解碼資料的簡單存取,非常適合需要從二維碼快速取得資料的應用程式。

適用情境

  • 行動支付系統
  • 活動門票驗證
  • 產品資訊查詢
  • 無接觸資料分享
  • 庫存管理

主要特色

  • 跨平台QR掃描
  • iOS with AVCaptureSession
  • Android with ZXing
  • 即時掃描
  • 簡單 API 結合

適合對象

  • 需要讀取二維碼的應用程式
  • 開發庫存工具的開發者
  • 新創公司創造非接觸式解決方案
  • 電子商務和零售應用
  • 活動和票務平台

使用建議

  • 兩個平台都需要相機權限
  • 僅限二維碼掃描(不支援產生)
  • 可能需要為攝像頭預覽添加額外的使用者介面
  • 性能取決於設備攝像頭的品質
  • 不支援二維條碼以外的條碼

原始 README

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

qrcode

A flutter plugin for scanning QR codes. Use AVCaptureSession in iOS and zxing in Android.

Usage

Use this package as a library
Add dependency

Add this to your package's pubspec.yaml file:

dependencies:
  qrcode: ^1.0.5
Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get
Import it

Now in your Dart code, you can use:

import 'package:qrcode/qrcode.dart';
Basic
class _MyAppState extends State<MyApp> {
  QRCaptureController _captureController = QRCaptureController();

  bool _isTorchOn = false;

  @override
  void initState() {
    super.initState();

    _captureController.onCapture((data) {
      print('onCapture----$data');
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Stack(
          alignment: Alignment.center,
          children: <Widget>[
            QRCaptureView(controller: _captureController),
            Align(
              alignment: Alignment.bottomCenter,
              child: _buildToolBar(),
            )
          ],
        ),
      ),
    );
  }

  Widget _buildToolBar() {
    return Row(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FlatButton(
              onPressed: () {
                _captureController.pause();
              },
              child: Text('pause'),
            ),
            FlatButton(
              onPressed: () {
                if (_isTorchOn) {
                  _captureController.torchMode = CaptureTorchMode.off;
                } else {
                  _captureController.torchMode = CaptureTorchMode.on;
                }
                _isTorchOn = !_isTorchOn;
              },
              child: Text('torch'),
            ),
            FlatButton(
              onPressed: () {
                _captureController.resume();
              },
              child: Text('resume'),
            ),
          ],
        );
  }
}

Integration

iOS

To use on iOS, you must add the following to your Info.plist

<key>NSCameraUsageDescription</key>
<string>Camera permission is required for qrcode scanning.</string>
<key>io.flutter.embedded_views_preview</key>
<true/>

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。