scanwedge 1.1.0

SDKflutter
Platformandroid

A Flutter plugin to communicate with the Zebra Datawedge

Scanwedge

Scanwedge is a Flutter plugin for Android devices that have hardware barcode scanner functionality.
It also has a battery status functionality that can be used to monitor or get the battery status of the device.
Currently it supports Honeywell, Datalogic, Newland and Zebra devices.
This will only work for these Android devices, but it will not have any negative impact on other devices.
Code inspired by sample code from Honeywell, Zebra and ofcourse the Flutter community. Thanks to @M-Ahal for adding Newland support.

Getting Started

Commands

CommandDescription
createProfileCreated a new scanner profile, input is a ProfileModel
disableScannerDisables the scanner, for Honeywell devices it will still "read" but not send the result
enableScannerEnables the scanner
initializeRequests and initialize the Scanwedge, this must be called before using the Scanwedge
isDeviceSupportedReturns true if it's a supported device, if this is false the other methods will be ignored when called
manufacturerReturns the manufacturer of the device
modelNameReturns the modelname of the device
osVersionReturns the OS version on the device
packageNameReturns the package name of the host application, this will also be used as default package name in [ScanProfile] if not set
productNameReturns the productname of the device
supportedDeviceReturns a [SupportedDevice] object with the information if the device is supported and the type
streamRequest a stream of barcode scans, returns barcodes scanned with the [ScanResult]
toggleScanningTriggers a scan (SOFTTRIGGER)
getBatteryStatusReturns the battery status of the device. This function might be removed from this package in the future
getExtendedBatteryStatusReturns the extended battery status of the device, this will return more information than [getBatteryStatus]
monitorBatteryStatusStarts monitoring the battery status, this will return a stream of [ExtendedBatteryStatus]
stopMonitoringBatteryStatusStops the battery status monitoring

 

Creating a new basic profile

final _scanwedgePlugin = await Scanwedge.initialize();

//Creating a new profile with the name TestProfile that only reads CODE128 barcodes with the length between 5 and 10
_scanwedgePlugin.createProfile(ProfileModel(profileName: 'TestProfile', enabledBarcodes: [BarcodeTypes.code128.create(minLength: 5, maxLength: 10)]))

ProfileModel

This class sets the scan profile

ProfileModel({
    required String profileName,                      // The name of the profile
    List<BarcodeConfig>? enabledBarcodes,             // A list of [BarcodeConfig] that will be enabled in the profile
    bool keepDefaults = true,                         // If true, the default enabled barcodes from the hardware used will be kept (together with [enabledBarcodes])
});

ZebraProfileModel

This class is a extended version of [ProfileModel] that adds more configuration options if the device is a Zebra device (will also work with other devices but then ignore the extra configuration) The extra options are: [aimType] - The type of aim, see [AimTypes], default is [AimType.trigger] [enableKeyStroke] - Enable sending scans to keyboard buffer (this is default set to false)

HoneywellProfileModel

This currently have no extra configuration options, so should use [ProfileModel] instead

SupportedDevice

This class is returned when calling [supportedDevice]

enum SupportedDevice { zebra, honeywell, invalid }

BarcodeConfig

Possibility to set configuration related to barcode scanning.

BarcodeConfig({
    required BarcodeTypes barcodeType,  // The [BarcodeTypes]
    int? minLength,                     // The minimum length of the barcode, ignored if null. Not all barcode types support this so check hardware vendor for the appropriate barcode type
    int? maxLength,                     // The maximum length of the barcode, ignored if null. Not all barcode types support this so check hardware vendor for the appropriate barcode type
});

Listening for scan events

To receive the scan events you can listen to the Stream

final _scanwedgePlugin=ScanwedgeChannel();
@override build()=>Card(
    child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
            const Text('Last scan:'),
            StreamBuilder(
                stream: _scanwedgePlugin.stream,
                builder: ((context, snapshot) => Text(
                        snapshot.hasData
                            ? snapshot.data.toString()
                            : snapshot.hasError
                                ? snapshot.error.toString()
                                : 'Scan something',
                        style: Theme.of(context).textTheme.titleMedium,
                    ))),
        ]
    )
);

AimTypes

This is a enum that sets the aim type for the scanner on Zebra devices

trigger
timedHold
timedRelease
pressAndRelease
presentation
continuousRead
pressAndSustain
pressAndContinue
timedContinuous

BarcodeTypes

aztec,
codabar,
code128,
code39,
code93,
datamatrix,
ean128,
ean13,
ean8,
gs1DataBar,
gs1DataBarExpanded,
i2of5,
mailmark,
maxicode,
pdf417,
qrCode,
upca,
upce0,
manual,     // Used for marking a barcode as manual input
unknown     // This is when it receives a unknown barcode, then check the [ScanResult.hardwareBarcodeType] for the actual barcode type