Last updated:
0 purchases
nfc io
Flutter NFC Reader #
A new flutter plugin to help developers looking to use internal hardware inside Android devices (For now, iOS coming soon) for reading NFC tags.
It starts a reading session that keeps scanning tags until it is manually turned off.
You can trigger the stop event manually using a dedicated function.
Supported NFC Format #
Platform
Supported Tags/Cards
Android
NDEF:,A, B, F, V, BARCODE, MIFARE
iOS (Coming Soon)
NDEF: NFC TYPE 1, 2, 3, 4, 5
Installation #
Add to pubspec.yaml:
dependencies:
nfc_io:
git:
url: [email protected]:agent306/nfc_io.git
ref: master
copied to clipboard
and then run the shell command
flutter packages get
copied to clipboard
import the plugin to your project:
import 'package:nfc_io/nfc_io.dart';
copied to clipboard
How to use #
Android setup #
Add these two lines to your AndroidManifest.xml on the top
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc"/>
copied to clipboard
iOS setup #
Coming soon...
Read NFC #
This function will return a stream, the read session will be kept open until otherwise closed.
The stream will return a NfcData model whenever an NFC tag/card is detected. This model contains:
Field
Description
id
Id of the tag
content
Content of the tag (Blank if not an NDEF)
error
If any error occurs, null otherwise
status
Either none, reading, read, stopped or error
Future<void> startNFC() async {
StreamSubscription _subscription = NfcIo.startReading.listen((NfcData data) {
print(data);
});
}
copied to clipboard
Stop NFC #
Future<void> stopNFC() async {
if (_subscription != null) {
_subscription.cancel();
NfcData result = await NfcIo.stopReading;
print(result);
}
}
copied to clipboard
For better details look at the demo app.
Getting Started #
This project is a starting point for a Flutter
plug-in package,
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
For help getting started with Flutter, view our
online documentation, which offers tutorials,
samples, guidance on mobile development, and a full API reference.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.