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

outdated

A Flutter plugin to use NFC. Supported on both Android and iOS.

nfc_manager #

A Flutter plugin to use NFC. Supported on both Android and iOS.

Note #

This plugin is still under development.

So please use with caution as there may be potential issues and breaking changes.

Feedback is welcome.

Setup #

Android Setup #

iOS Setup #

Usage #

Reading NDEF #

NfcManager.instance.startNdefSession(
  alertMessageIOS: '[Any message displayed on the iOS system UI]',
  onNdefDiscovered: (NfcNdef ndef) {
    print(ndef);
  },
);

Writing NDEF #

NfcManager.instance.startNdefSession(
  alertMessageIOS: '...',
  onNdefDiscovered: (NfcNdef ndef) async {
    if (!ndef.isWritable) {
      print('Tag is not ndef writable.');
      return;
    }

    final NdefMessage message = NdefMessage([
      NdefRecord.createTextRecord('Hello World'),
      NdefRecord.createUriRecord(Uri.parse('https://flutter.dev')),
      NdefRecord.createMimeRecord('plain/text', Uint8List.fromList('Hello World'.codeUnits)),
      NdefRecord.createExternalRecord([domain string], [type string], [data uint8list]),
    ]);

    try {
      await ndef.writeNdef(message);
    } catch (e) {
      // handle error
    }
  },
);

Reading Tag #

NfcManager.instance.startTagSession(
  alertMessageIOS: '...',
  pollingOptions: {NfcTagPollingOption.iso14443, NfcTagPollingOption.iso15693, NfcTagPollingOption.iso18092},
  onTagDiscovered: (NfcTag tag) {
    print(tag);
    print(tag.ndef); // You can also read NDEF.
  },
);

Stop Session #

NfcManager.instance.stopSession(
  alertMessageIOS: [success message string],
  errorMessageIOS: [error message string],
);
411
likes
30
pub points
98%
popularity

Publisher

verified publisherokadan.net

A Flutter plugin to use NFC. Supported on both Android and iOS.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on nfc_manager