flutter_nfc_reader 0.0.8 flutter_nfc_reader: ^0.0.8 copied to clipboard
A nfc reader plugin for iOS and Android. This plugin allow you to trigger NFC native reading session on device.
Flutter NFC Reader #
A new flutter plugin to help developers looking to use internal hardware inside iOS or Android devices for reading NFC tags.
The system activate a pooling reading session that stops automatically once a tag has been recognised. You can also trigger the stop event manually using a dedicated function.
How to use #
Android setup #
Add those two lines to your AndroidManifest.xml
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
iOS Setup #
- Enable Capabilities / Near Field Communication Tag Reading.
- Info.plist file, add Privacy - NFC Scan Usage Description with string value NFC Tag.
Read NFC #
This function will return a promise when a read occurs, till that very moment the reading session is open.
In order to stop a reading session you need to use stop
function.
Future<Null> NfcRead() async {
String response;
try {
final String result = await FlutterNfcReader.read;
if (result != null) {
response = '';
} else {
response = result;
}
} on PlatformException {
response = '';
}
setState(() {
_nfcActive = true;
_nfcData = response;
});
}
Stop NFC #
Future<Null> NfcStop() async {
bool response;
try {
final bool result = await FlutterNfcReader.stop;
response = !result;
} on PlatformException {
response = false;
}
setState(() {
_nfcActive = response;
});
}
For better details look at the demo app.
Getting Started #
For help getting started with Flutter, view our online documentation.
For help on editing plugin code, view the documentation.