![]() |
VOOZH | about |
NFC that stands for Near Field Communication, is a very short range wireless technology that allows us share small amount of data between devices. Through this technology we can share data between an NFC tag and an android device or between two android devices. A maximum of 4 cm distance is required to establish this connection. In this articles, we will be developing a basic application that involved communicating between an Android Device and a NFC Tag.
Prerequisites
To create a new project in Android Studio please refer to Creating a Simple Application in Flutter.
dependencies:
flutter:
sdk: flutter
nfc_manager: ^3.5.0
To know more about package refer : nfc_manager
Navigate to android > app > src > main > AndroidManifest.xml and add the following permissions under the manifest tag.
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required ="true" />
main.dart include 3 primary functionalities to execute NFC in flutter application.
-
-
-
The whole Application code for this is provided below:
main.dart:
Output:
Note : default NFC reader can pop-up in your screen. So, the solution is preventing default Android NFC reader.
If you get any uneven behavior of the app like opening a default pop-up in the middle of the process then to control that behavior add below code in android > app > src > main > kotlin > com > example > oyo > MainActivity.kt.
MainActivity.kt:
For GitHub link for the repository for the application is refer to this link.