nfc_st25_flutter_plugin
is a Flutter plugin that enables interaction with ISO 15693 NFC tags
using NFC technology on iOS and Android devices. The plugin exposes functions to read blocks,
present passwords, and start NFC sessions. It's particularly useful for those working with ST25 tags.
Official ST Java and ObjC libraries are included in native code.
Add the following line to your pubspec.yaml file to include the library in your project:
dependencies: nfc_st25_flutter_plugin: path: ../nfc_st25_flutter_plugin # Replace with the actual path or published version
Run the following command to update dependencies:
flutter pub get
This library exposes the following functions in the main Dart file:
Starts an NFC session to search for ISO 15693 tags.
await NfcSt25.startNfcSession();
Checks whether the device supports NFC.
bool isAvailable = await NfcSt25.checkNfcAvailability(); print(isAvailable); // Prints true if NFC is available
Reads a single block of data from an ISO 15693 NFC tag.
- int blockNumber: The block number to read.
await NfcSt25.readBlock(4); // Reads block number 4
Reads multiple blocks of data starting from a specific address.
- int address: The starting address.
- int blocks: The number of blocks to read.
await NfcSt25.readBlocks(0, 3); // Reads 3 blocks starting from address 0
Presents a password to the NFC tag to unlock protected operations.
- int passwordNumber: The number of the password to use.
- List password: The password in List format.
await NfcSt25.presentPassword(1, [0x12, 0x34, 0x56, 0x78]); // Presents the password to the tag
To use this library on iOS devices, you need to enable NFC in the iOS project settings. Modify the ios/Runner/Info.plist file to add the NFC usage description:
NFCReaderUsageDescription This app uses NFC to interact with compatible tags.
Ensure that the Android project has NFC permissions. Modify the AndroidManifest.xml file by adding the following permissions:
import 'package:nfc_st25_flutter_plugin/nfc_st25.dart';
void main() async { // Check if NFC is available bool isAvailable = await NfcSt25.checkNfcAvailability();
if (isAvailable) { // Start an NFC session await NfcSt25.startNfcSession();
// Read a block
await NfcSt25.readBlock(0);
// Present a password to the tag
await NfcSt25.presentPassword(1, [0x12, 0x34, 0x56, 0x78]);
} else { print("NFC not available on this device"); } }
If you would like to contribute to improving this library, feel free to open an issue or submit a pull request.
This library is distributed under the MIT License. See the LICENSE file for more details.