nfc_manager

A Flutter plugin for accessing the NFC features on Android and iOS.

Setup

Android

iOS

Usage

Handling the Session

import 'package:nfc_manager/nfc_manager.dart';

// Check is NFC is available.
bool isAvailable = await NfcManager.instance.isAvailable();

// 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, it's converted into a vendor-specific tag instance by calling a static method from(tag).

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

final ndef = Ndef.from(tag);

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

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

The following vendor-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 (External Packages)