flutter_nfc_compatibility 0.0.4 flutter_nfc_compatibility: ^0.0.4 copied to clipboard
A nfc compatibility plugin for Android. It will differentiate States of NFC (Not Enabled, Not Supported, Enabled)
Flutter NFC Compatibility Check #
Installation #
Add to pubspec.yaml:
dependencies:
flutter_nfc_compatibility: ^0.0.3
import 'package:flutter_nfc_compatibility/flutter_nfc_compatibility.dart';
How to use #
Android setup #
Add those two lines to your AndroidManifest.xml
on the top
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
Usage #
Handling Session
// Check availability
var nfcCompatibility = await FlutterNfcCompatibility.checkNFCAvailability();
// Different states of the NFC availibality
if(nfcCompatibility == NFCAvailability.Enabled ){
writerController.text = "Enabled";
}else if(nfcCompatibility == NFCAvailability.Disabled ){
writerController.text = "Disabled";
}else{
writerController.text = "Not Supported";
}
NFCAvailability can differentiate the states of the NFC