flutter_nfc_kit icon indicating copy to clipboard operation
flutter_nfc_kit copied to clipboard

Unable to read/write tags

Open suraj740 opened this issue 1 year ago • 10 comments

Hi, i am using mifare ultralight, ndef tag on my android phone (Android Version 12) using the example application provided. Its unable to read/write tag using the example application.

Other apps such as NFC tool is able to read/write the same tag.

suraj740 avatar Sep 12 '23 20:09 suraj740

Please provide some code to reproduce the problem, and any error log when using flutter_nfc_kit.

Harry-Chen avatar Sep 13 '23 04:09 Harry-Chen

I have NFC tag which has some data in it, but the example application is unable to read or write which is provided by flutter_nfc_kit.

I am running the same example which is present flutter_nfc_kit repo under example folder.

suraj740 avatar Sep 13 '23 21:09 suraj740

I have NFC tag which has some data in it, but the example application is unable to read or write which is provided by flutter_nfc_kit.

I am running the same example which is present flutter_nfc_kit repo under example folder.

Are you using the write ndef functionality? Please provide some logs so we can look into this problem.

Harry-Chen avatar Sep 14 '23 04:09 Harry-Chen

Below are the logs which i am getting while writing,

,0-1080,2295 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController( 9057): show(ime(), fromIme=true)
D/InputMethodManager( 9057): showSoftInput() view=io.flutter.embedding.android.FlutterView{2774a4e VFE...... .F...... 0,0-1080,2295 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController( 9057): show(ime(), fromIme=true)
D/InputMethodManager( 9057): showSoftInput() view=io.flutter.embedding.android.FlutterView{2774a4e VFE...... .F...... 0,0-1080,2295 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController( 9057): show(ime(), fromIme=true)
I/flutter ( 9057): #0      _$NFCTagFromJson (package:flutter_nfc_kit/flutter_nfc_kit.g.dart:47:52)
I/flutter ( 9057): #1      new NFCTag.fromJson (package:flutter_nfc_kit/flutter_nfc_kit.dart:144:57)
I/flutter ( 9057): #2      FlutterNfcKit.poll (package:flutter_nfc_kit/flutter_nfc_kit.dart:261:19)
I/flutter ( 9057): <asynchronous suspension>
I/flutter ( 9057): #3      _MyAppState.build.<anonymous closure> (package:flutter_nfc_kit_example/main.dart:172:44)
I/flutter ( 9057): <asynchronous suspension>

and while reading when i click in start polling , nothing happens no logs are coming nfc_flutter_kit

suraj740 avatar Sep 14 '23 19:09 suraj740

Seems no tags are polled. Maybe you can just invoke poll and see if it returns.

Harry-Chen avatar Sep 15 '23 04:09 Harry-Chen

Even after invoking poll no logs are printing after this,

 NFCTag tag = await FlutterNfcKit.poll();
 print('tag'); //  this is not printing in console

suraj740 avatar Sep 15 '23 19:09 suraj740

Sorry but with no further details, we cannot help to diagnose your problem

Harry-Chen avatar Oct 30 '23 14:10 Harry-Chen

Hello, I am experiencing the same issue. I am using a Samsung S20FE with Android 13. The tag is an ISO 14443-3A NXP - Mifare Classic 1k

I am just trying to read the tag, because I need the serialnumber from it. I am using the provided example code in this repo and the latest nfc kit version as of writing this. After I turned on all exceptions this is the exception I get. grafik

amasuke55 avatar Nov 22 '23 12:11 amasuke55

Hello, I am experiencing the same issue. I am using a Samsung S20FE with Android 13. The tag is an ISO 14443-3A NXP - Mifare Classic 1k

I am just trying to read the tag, because I need the serialnumber from it. I am using the provided example code in this repo and the latest nfc kit version as of writing this. After I turned on all exceptions this is the exception I get. grafik

I also got that error.

More details:

#0      _$NFCTagFromJson (package:flutter_nfc_kit/flutter_nfc_kit.g.dart:47:52)
#1      new NFCTag.fromJson (package:flutter_nfc_kit/flutter_nfc_kit.dart:145:57)
#2      FlutterNfcKit.poll (package:flutter_nfc_kit/flutter_nfc_kit.dart:344:19)
<asynchronous suspension>
#3      _MyAppState.build.<anonymous closure> (package:betapper/main.dart:103:48)
<asynchronous suspension>

image

Looks like 'mifareInfo' value is not a valid json:

{type=ultralight_c, size=176, blockSize=4, blockCount=44, sectorCount=null}

https://github.com/nfcim/flutter_nfc_kit/blob/master/lib/flutter_nfc_kit.g.dart#L47C57-L47C57

So that line throws the error because that can't be converted to that map

demo: https://dartpad.dev/?id=5533bfd8cb4302778488c919cf0c316c

Replacing that with null in the library did it for me and my tags work now, but that's not a good solution :)

Charly6596 avatar Nov 28 '23 21:11 Charly6596

Same issue here, updated from version 3.3.1 to 3.4.1 and getting this when tag is picked up:

Unhandled Exception: type 'String' is not a subtype of type 'Map<String, dynamic>' in type cast
 #0      _$NFCTagFromJson (package:flutter_nfc_kit/flutter_nfc_kit.g.dart:47:52)
 #1      new NFCTag.fromJson (package:flutter_nfc_kit/flutter_nfc_kit.dart:145:57)
 #2      FlutterNfcKit.poll (package:flutter_nfc_kit/flutter_nfc_kit.dart:344:19)

Tag type: ISO 14443-3A Device: Pixel 7 - Android 14

Areion0 avatar Dec 05 '23 14:12 Areion0

This is fixed in v3.4.2.

Harry-Chen avatar Apr 04 '24 09:04 Harry-Chen