NFC read/write with flutter

Zveratko picture Zveratko · Feb 15, 2019 · Viewed 8.7k times · Source

I'd like to give a try with flutter, but so far I have found only NFC reader plugin. I will need two other things.

  • react on NFC tag present intent and then maybe use NFC plugin to read it

  • write to NFC tag, probably using Platform channels

I just need to confirm it is feasible at all with flutter and will need the kick in the right direction, before I will leave plain android.

Answer

U_flow picture U_flow · Jul 29, 2019

perhaps I am a little late to the party, however as I just tackled a very similar problem, I want to weigh in on this topic: So reading/writing NFC with Flutter is possible. As mentioned before you need a platform channel in order hand the command to the native system, AND an event channel, if you want to read data to your flutter app, to accomplish this task.

The best way would be, if a plugin was available to handle this, however I could not get the one which you mentioned too to work with my flutter app (specifically, because I tried with IOS and swift). However here are some ressources, from which I puzzled together my system:

  • Communication from flutter to native system via platform channels: This link is the offical flutter page which interestingly only described the communication from flutter to native system, but not the other way around. For the other way you need:
  • Communication from native system to flutter app via event channels: (yes you need a different channel for the communication back to the flutter app). This example is only for android. For swift, all I could find was this ressource, which however seems to be a bit old.
  • NFC Tutorial for IOS: This is actually pretty simple as long as you have a developper account. A good minimalistic tutorial can be found here
  • NFC Tutorial for Android: This is actually even simpler, as nfc is longer established on android. I like this one