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';
NfcAvailability availability = await NfcManager.instance.checkAvailability();
if (availability != NfcAvailability.enabled) {
print('NFC may not be supported or may be temporarily disabled.');
return;
}
NfcManager.instance.startSession(
pollingOptions: {NfcPollingOption.iso14443},
onDiscovered: (NfcTag tag) async {
print(tag);
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;
}
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)