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

套件詳情v3.7.0

flutter_nfc_kit

在 Android、iOS 與 Web 上提供 NFC 功能,包含讀取元資料、讀寫 NDEF 記錄,以及與 NFC 標籤/卡進行第 3 層與第 4 層資料交換

AndroidiOSWeb
近 30 天下載
8.6萬
喜歡數
280
Pub 分數
160

安裝套件

flutter pub add flutter_nfc_kit

套件介紹

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

flutter_nfc_kit 是一個跨平台的 Flutter 套件,可在 Android、iOS 和 Web 上啟用 NFC 功能。它允許開發者讀取和寫入 NDEF 記錄,存取 NFC 標籤的元資料,並在第 3 層和第 4 層執行低階 transceive 操作。該套件支援廣泛的 NFC 使用情境,包括非接觸式資料交換、智慧標籤互動以及與 NFC 卡的安全通訊。透過跨平台一致的 API,它簡化了將 NFC 功能整合至 Flutter 應用程式的過程。

適用情境

  • 讀取和寫入NDEF記錄
  • 訪問NFC標籤元數據
  • 執行低階級NFC通訊
  • 建構非接觸式支付或票務應用
  • 啟用智慧海報互動
  • 與NFC啟用的物聯網設備整合

主要特色

  • 跨平台支援(Android、iOS、Web)
  • NDEF記錄讀取和寫入
  • 從NFC標籤中提取元數據
  • 第3層和第4層收發功能
  • 跨平台一致的 API
  • 即時NFC標籤檢測

適合對象

  • 開發基於NFC的移動應用的開發者
  • 需要非接觸式數據傳輸的應用程式
  • 智慧裝置互動系統
  • 活動票務和訪問控制解決方案
  • 物聯網和嵌入式系統整合

使用建議

  • 需要具備NFC硬體的裝置
  • 權限必須在每個平台上進行處理
  • Web 支援僅限相容瀏覽器
  • iOS 需要背景模式設定
  • 性能可能因設備和標籤類型而異
  • 對高級NFC協議的支援有限

原始 README

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

Flutter NFC Kit

pub version Test Build Example App

Yet another plugin to provide NFC functionality on Android, iOS and browsers (by WebUSB, see below).

This plugin's functionalities include:

  • read metadata and read & write NDEF records of tags / cards complying with:
    • ISO 14443 Type A & Type B (NFC-A / NFC-B / MIFARE Classic / MIFARE Plus / MIFARE Ultralight / MIFARE DESFire)
    • ISO 18092 (NFC-F / FeliCa)
    • ISO 15693 (NFC-V)
  • R/W block / page / sector level data of tags complying with:
    • MIFARE Classic / Ultralight (Android only, MIFARE Classic Read & Write block for iOS)
    • ISO 15693 (iOS only)
  • transceive raw commands with tags / cards complying with:
    • ISO 7816 Smart Cards (layer 4, in APDUs)
    • other device-supported technologies (layer 3, in raw commands, see documentation for platform-specific supportability)

Note that due to API limitations, not all operations are supported on all platforms. You are welcome to submit PRs to add support for any standard-specific operations.

This library uses ndef for NDEF record encoding & decoding.

Contributing

Please refer to CONTRIBUTING.md for more information.

Setup

Android

We have the following minimum version requirements for Android plugin:

  • Java 17
  • Gradle 8.9
  • Android SDK 24 (you must set corresponding jvmTarget in you app's build.gradle)
  • Android Gradle Plugin 8.7

To use this plugin on Android, you also need to:

iOS

This plugin now supports Swift package manager, and requires iOS 13+.

Web

The web version of this plugin does not actually support NFC in browsers, but uses a specific WebUSB protocol, so that Flutter programs can communicate with dual-interface (NFC / USB) devices in a platform-independent way.

Make sure you understand the statement above and the protocol before using this plugin.

Usage

We provide simple code example and a example application.

Refer to the documentation for more information.

Error codes

We use error codes with similar meaning as HTTP status code. Brief explanation and error cause in string (if available) will also be returned when an error occurs.

Operation Mode

We provide two operation modes: polling (default) and event streaming. Both can give the same NFCTag object. Please see example for more details.

Performance Optimization (Android)

For Android applications, you can optimize NFC tag detection performance using the androidReaderModeFlags parameter:

// Skip automatic NDEF discovery for ~500ms faster detection
// and disable platform sounds for custom feedback
const flags = 0x80 | 0x100; // FLAG_READER_SKIP_NDEF_CHECK | FLAG_READER_NO_PLATFORM_SOUNDS

final tag = await FlutterNfcKit.poll(
  androidReaderModeFlags: flags,
);

Common flags from NfcAdapter:

  • 0x80 - FLAG_READER_SKIP_NDEF_CHECK: Skip automatic NDEF discovery, improving detection speed by ~500ms
  • 0x100 - FLAG_READER_NO_PLATFORM_SOUNDS: Disable system beep/vibration for custom audio/haptic feedback

These flags are particularly useful for applications that:

  • Need fast tag detection (e.g., access control, fast payments)
  • Implement custom user feedback instead of system sounds
  • Use custom NDEF reading logic instead of automatic discovery

所屬分類

依賴

依賴清單 6 項

原始碼儲存庫

使用此套件的專案