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

套件詳情v4.3.0

nfc_manager

一個 Flutter 外掛程式,可在 Android 和 iOS 上提供對 NFC 功能的存取。

AndroidiOS
近 30 天下載
10.1萬
喜歡數
532
Pub 分數
160

安裝套件

flutter pub add nfc_manager

套件介紹

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

nfc_manager 是一個 Flutter 插件,可在 Android 和 iOS 設備上啟用 NFC(近場通訊)功能。它允許開發者讀取和寫入 NFC 標籤,檢測附近的 NFC 設備,並處理 NDEF(NFC 數據交換格式)訊息。該插件提供跨平台的一致 API,簡化了將 NFC 功能整合到 Flutter 應用程式中的過程。支援多種 NFC 操作,如標籤檢測、讀取、寫入和背景處理。適用於無接觸式支付系統、智慧海報、存取控制和資料分享應用。

適用情境

  • 讀取NFC標籤
  • 向NFC標籤寫入數據
  • 實現無接觸支付
  • 建立智慧海報
  • 啟用存取控制系統

主要特色

  • 跨平台NFC支援
  • NDEF訊息處理
  • 標籤檢測和讀取
  • 背景NFC掃描
  • 用於常見 NFC 任務的簡單 API

適合對象

  • 需要NFC互動的行動應用程式
  • 開發無接觸解決方案的開發者
  • 使用智慧卡或信標的應用程式
  • 同時針對 Android 和 iOS 的項目

使用建議

  • 需要具備NFC硬體的裝置
  • 與 Android 相比,iOS 的 NFC 功能有限
  • 權限必須由使用者授予
  • 並非所有Android設備都支援完整的NFC功能

原始 README

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

nfc_manager

A Flutter plugin providing access to NFC features on Android and iOS.

Setup

Android
iOS

Usage

Handling the Session
import 'package:nfc_manager/nfc_manager.dart';

// Check the availability of NFC on the current device.
NfcAvailability availability = await NfcManager.instance.checkAvailability();

if (availability != NfcAvailability.enabled) {
  print('NFC may not be supported or may be temporarily disabled.');
  return;
}

// Start the session.
NfcManager.instance.startSession(
  pollingOptions: {NfcPollingOption.iso14443}, // You can also specify iso18092 and iso15693.
  onDiscovered: (NfcTag tag) async {
    // Do something with an NfcTag instance...
    print(tag);

    // Stop the session when no longer needed.
    await NfcManager.instance.stopSession();
  },
);
Working with NfcTag

An NfcTag instance is typically not used directly. Instead, convert it to a platform-specific tag class by calling that class's static method from.

import 'package:nfc_manager/nfc_manager.dart';
import 'package:nfc_manager_ndef/nfc_manager_ndef.dart';

final Ndef ndef = Ndef.from(tag);

if (ndef == null) {
  print('This tag is not compatible with NDEF.');
  return;
}

// Do something with an Ndef instance...
print(ndef);

The following platform-specific tag classes are available:

Android only
  • NfcAAndroid
  • NfcBAndroid
  • NfcFAndroid
  • NfcVAndroid
  • IsoDepAndroid
  • MifareClassicAndroid
  • MifareUltralightAndroid
  • NfcBarcodeAndroid
  • NdefAndroid
  • NdefFormatableAndroid
iOS only
  • FeliCaIos
  • MiFareIos
  • Iso15693Ios
  • Iso7816Ios
  • NdefIos
Cross-platform abstractions (separate packages)

所屬分類

依賴

依賴清單 2 項

  • meta^1.17.0
  • ndef_record^1.4.2

原始碼儲存庫

使用此套件的專案