A Flutter plugin that provides seamless integration with Urovo's Android RFID hardware, enabling Flutter applications to interact with Urovo RFID readers. The plugin wraps Urovo's native Android SDK, exposing a clean and easy-to-use Dart API.
- Power on/off and connect to Urovo RFID readers
- Start and stop continuous inventory scanning
- Perform single inventory scans
- Retrieve hardware and firmware information
- Real-time tag events via stream (EPC, TID, RSSI)
- Optimized for performance with minimal battery impact
- Built with null safety
- Flutter 3.0.0 or later
- Android 5.0 (API level 21) or later
- Urovo Android device with RFID capabilities
Add the following to your pubspec.yaml:
dependencies:
flutter_urovo_rfid: ^0.1.0Then run:
flutter pub getimport 'package:flutter_urovo_rfid/flutter_urovo_rfid.dart';// Power on and connect to the RFID module
final state = await FlutterUrovoRfid.openRfid();
print('RFID module state: $state');// Subscribe to tag events
final subscription = FlutterUrovoRfid.scanStream.listen((tag) {
final epc = tag['epc']; // Electronic Product Code
final tid = tag['tid']; // Tag ID
final rssi = tag['rssi'] as int; // Signal strength
print('Tag detected - EPC: $epc, TID: $tid, RSSI: $rssi');
});
// Start scanning
await FlutterUrovoRfid.startReading();
// Stop scanning
await FlutterUrovoRfid.stopReading();
// Don't forget to cancel the subscription when done
await subscription.cancel();// Perform a single inventory scan
final tags = await FlutterUrovoRfid.singleInventory();
print('Found ${tags.length} tags: $tags');final fwVersion = await FlutterUrovoRfid.getFirmwareVersion();
print('Firmware version: $fwVersion');// Power off the RFID module when done
await FlutterUrovoRfid.closeRfid();void initReader() async {
// Power on and connect
final state = await FlutterUrovoRfid.openRfid();
print('RFID state: $state');
// Listen to tag events
FlutterUrovoRfid.scanStream.listen((event) {
final epc = event['epc'];
final tid = event['tid'];
final rssi = event['rssi'];
print('Tag: EPC=$epc TID=$tid RSSI=$rssi');
});
}
void startScanning() async {
await FlutterUrovoRfid.startReading();
}| Method | Description | Returns |
|---|---|---|
openRfid() |
Powers on and initializes the RFID module | Future<String> - Status message |
closeRfid() |
Powers off the RFID module | Future<void> |
startReading() |
Starts continuous inventory scanning | Future<void> |
stopReading() |
Stops continuous inventory scanning | Future<void> |
singleInventory() |
Performs a single inventory scan | Future<List<Map<String, dynamic>>> - List of scanned tags |
getFirmwareVersion() |
Retrieves the firmware version | Future<String> - Firmware version string |
| Stream | Description | Event Type |
|---|---|---|
scanStream |
Stream of tag scan events | Map<String, dynamic> with keys: epc, tid, rssi |
All methods may throw a PlatformException if the operation fails. Make sure to handle potential errors:
try {
await FlutterUrovoRfid.openRfid();
} on PlatformException catch (e) {
print('Failed to initialize RFID: ${e.message}');
}Add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />For Android 12 and above, you'll also need to add these to your AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />-
RFID module not initializing
- Ensure the device has RFID capabilities
- Check if the RFID module is properly connected
- Verify that all required permissions are granted
-
No tags being detected
- Ensure tags are within the reader's range
- Check if the RFID antenna is properly connected
- Verify that the correct frequency is being used for your tags
This plugin depends on the proprietary Urovo RFID SDK. To compile and run successfully, you must obtain the SDK JAR/AAR files from Urovo and place them into the plugin's android/src/main/libs directory (create it if it doesn't exist). The Gradle script is configured to include any .jar or .aar files found there.
- Obtain the Urovo RFID SDK (
.aaror.jarfiles) from Urovo - Create the directory if it doesn't exist:
mkdir -p android/src/main/libs
- Copy the Urovo SDK files to
android/src/main/libs/ - The plugin will automatically include these files in the build
Because the Urovo SDK uses reflection and dynamic loading, ProGuard rules have been provided in android/proguard-rules.pro to preserve required classes. If you're using ProGuard or R8 in your app, make sure to include these rules.
See the example app in the example/ directory for a complete demonstration of how to use this plugin in a Flutter application.
Add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />For Android 12 and above, you'll also need to add these to your AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Acknowledgments
- Urovo Technology Co., Ltd. for their Android RFID SDK
- The Flutter team for their excellent plugin system