Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class NfcManagerPlugin: FlutterPlugin, MethodCallHandler, ActivityAware {
override fun onMethodCall(call: MethodCall, result: Result) {
when (call.method) {
"Nfc#isAvailable" -> handleNfcIsAvailable(call, result)
"Nfc#isSupported" -> handleNfcIsSupported(call, result)
"Nfc#startSession" -> handleNfcStartSession(call, result)
"Nfc#stopSession" -> handleNfcStopSession(call, result)
"Nfc#disposeTag" -> handleNfcDisposeTag(call, result)
Expand Down Expand Up @@ -96,6 +97,10 @@ class NfcManagerPlugin: FlutterPlugin, MethodCallHandler, ActivityAware {
result.success(adapter?.isEnabled == true)
}

private fun handleNfcIsSupported(call: MethodCall, result: Result) {
result.success(this.adapter != null)
}

private fun handleNfcStartSession(call: MethodCall, result: Result) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
result.error("unavailable", "Requires API level 19.", null)
Expand Down
4 changes: 4 additions & 0 deletions lib/src/nfc_manager/nfc_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class NfcManager {
return channel.invokeMethod('Nfc#isAvailable').then((value) => value!);
}

/// Checks whether the NFC features are supported in the hardware level
Future<bool> isSupported() async {
return channel.invokeMethod('Nfc#isSupported').then((value) => value!);
}
/// Start the session and register callbacks for tag discovery.
///
/// This uses the NFCTagReaderSession (on iOS) or NfcAdapter#enableReaderMode (on Android).
Expand Down