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