nfc_manager 1.3.2 copy "nfc_manager: ^1.3.2" to clipboard
nfc_manager: ^1.3.2 copied to clipboard

outdated

A Flutter plugin to manage the NFC features. Supported on both Android and iOS.

nfc_manager #

A Flutter plugin to manage the NFC features. Supported on both Android and iOS.

Setup #

Android Setup #

iOS Setup #

Usage #

Managing Session #

// Check availability
bool isAvailable = await NfcManager.instance.isAvailable();

// Start session and register callback.
NfcManager.instance.startTagSession(onDiscovered: (NfcTag tag) async {
  // Manipulating tag
});

// Stop session and unregister callback.
NfcManager.instance.stopSession();

Manipulating NDEF #

// Obtain an Ndef instance from tag
Ndef ndef = Ndef.fromTag(tag);

if (ndef == null) {
  print('Tag is not ndef');
  return;
}

// Get an NdefMessage instance cached at discovery time
NdefMessage cachedMessage = ndef.cachedMessage;

// Create an NdefMessage instance you want to write.
NdefMessage message = NdefMessage([
  NdefRecord.createText('Hello'),
  NdefRecord.createUri(Uri.parse('https://flutter.dev')),
  NdefRecord.createMime('text/plain', Uint8List.fromList('Hello'.codeUnits)),
  NdefRecord.createExternal('mydomain', 'mytype', Uint8List.fromList('mydata'.codeUnits)),
]);

if (!ndef.isWritable) {
  print('Tag is not ndef writable');
  return;
}

// Write an NdefMessage
try {
  await ndef.write(message);
} catch (e) {
  // handle error
  return;
}

Manipulating Platform-Specific-Tag #

The following platform-specific-tag classes are available:

iOS

  • MiFare
  • FeliCa
  • ISO15693
  • ISO7816

Android

  • NfcA
  • NfcB
  • NfcF
  • NfcV
  • IsoDep

Example

MiFare miFare = MiFare.fromTag(tag);

if (miFare == null) {
  print('MiFare is not available on this tag');
  return;
}

Uint8List response = await miFare.sendMiFareCommand(...);
411
likes
0
pub points
98%
popularity

Publisher

verified publisherokadan.net

A Flutter plugin to manage the NFC features. Supported on both Android and iOS.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on nfc_manager