zebra_tc 1.0.0
zebra_tc: ^1.0.0 copied to clipboard
Flutter plugin for Zebra TC series built-in barcode scanner via DataWedge.
zebra_tc #
Flutter plugin for Zebra TC series Android devices that integrates with the built-in barcode scanner via Zebra DataWedge.
Listens for scan results using a BroadcastReceiver, manages DataWedge profiles, and exposes controls for the scanner and flashlight — all through a simple Dart API.
Platform support #
| Android |
|---|
| ✅ |
Requires a Zebra device with DataWedge installed (pre-installed on all Zebra TC/MC/EC series devices).
Getting started #
1. Add dependency #
dependencies:
zebra_tc: ^1.0.0
2. Create a DataWedge profile #
Call createProfile() once on app start (e.g. in initState). DataWedge uses CREATE_IF_NOT_EXIST logic — safe to call on every launch.
final zebra = ZebraTc();
@override
void initState() {
super.initState();
zebra.createProfile('MyAppProfile');
}
This automatically:
- Creates a DataWedge profile linked to your app's package
- Enables the Barcode plugin with
scanner_selection: auto - Configures Intent output with broadcast delivery to
com.zebratc.zebra_tc.SCAN
Usage #
Listen for scan results #
scanStream registers a BroadcastReceiver on first listen and unregisters it on cancel. Use a StreamSubscription and cancel it in dispose.
StreamSubscription<ZebraScan>? _sub;
void startListening() {
_sub = zebra.scanStream.listen((scan) {
print('Barcode: ${scan.barcode}');
print('Symbology: ${scan.symbology}');
});
}
@override
void dispose() {
_sub?.cancel();
super.dispose();
}
ZebraScan fields:
| Field | Type | Description |
|---|---|---|
barcode |
String |
Decoded barcode value |
symbology |
String |
Barcode type (e.g. LABEL-TYPE-EAN128, LABEL-TYPE-QRCODE) |
Enable / disable scanner #
await zebra.enableScanner(); // RESUME_PLUGIN
await zebra.disableScanner(); // SUSPEND_PLUGIN
Soft scan trigger #
Programmatically trigger the scanner as if the physical button was pressed:
await zebra.startScan(); // START_SCANNING
await zebra.stopScan(); // STOP_SCANNING
Flashlight (torch) #
await zebra.setFlash(enabled: true); // torch on
await zebra.setFlash(enabled: false); // torch off
Note: flashlight availability depends on the device model and DataWedge version.
API reference #
class ZebraTc {
Stream<ZebraScan> get scanStream;
Future<void> createProfile(String name);
Future<void> enableScanner();
Future<void> disableScanner();
Future<void> startScan();
Future<void> stopScan();
Future<void> setFlash({required bool enabled});
}
How it works #
createProfile()sends DataWedge API intents to create a profile and bind it to your app's package name.- DataWedge broadcasts scan results as intents with action
com.zebratc.zebra_tc.SCAN. - The plugin registers a
BroadcastReceiverwhenscanStreamis listened to, parses the intent extras, and emitsZebraScanobjects to the Dart stream. - The receiver is automatically unregistered when the stream subscription is cancelled.
Requirements #
- Android SDK 24+
- Zebra device with DataWedge (TC20, TC21, TC25, TC26, TC51, TC52, TC57, TC70, TC72, TC77, MC series, etc.)
- DataWedge 6.4+ recommended