搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目