From 6daf38e6664ab312bd1bf772e1796f34aebf5565 Mon Sep 17 00:00:00 2001 From: TimNew Date: Fri, 21 Jan 2022 01:22:58 +1100 Subject: [PATCH] Break execution when NDEF is not writable (#63) * Break execution when ndef is not writable * Break writeNDEF when tag isn't writable --- .../main/kotlin/im/nfc/flutter_nfc_kit/FlutterNfcKitPlugin.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/im/nfc/flutter_nfc_kit/FlutterNfcKitPlugin.kt b/android/src/main/kotlin/im/nfc/flutter_nfc_kit/FlutterNfcKitPlugin.kt index 0e9a963..6ef7004 100644 --- a/android/src/main/kotlin/im/nfc/flutter_nfc_kit/FlutterNfcKitPlugin.kt +++ b/android/src/main/kotlin/im/nfc/flutter_nfc_kit/FlutterNfcKitPlugin.kt @@ -79,7 +79,7 @@ class FlutterNfcKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { } else true } - val switchTechnology = { target: TagTechnology, other: TagTechnology? -> + val switchTechnology = { target: TagTechnology, other: TagTechnology? -> if (!target.isConnected) { // close previously connected technology if (other !== null && other.isConnected) { @@ -216,6 +216,7 @@ class FlutterNfcKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { val ndef = ndefTechnology!! if (ndef.isWritable() == false) { result.error("405", "Tag not writable", null) + return } thread { try { @@ -259,6 +260,7 @@ class FlutterNfcKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { val ndef = ndefTechnology!! if (ndef.isWritable() == false) { result.error("405", "Tag not writable", null) + return } thread { try {