flutter_datawedge 3.0.0-dev.1 copy "flutter_datawedge: ^3.0.0-dev.1" to clipboard
flutter_datawedge: ^3.0.0-dev.1 copied to clipboard

A Flutter package to communicate with Zebra DataWedge scanners using the DataWedge Intent API

flutter_datawedge #

pub package

A Flutter package to communicate with Zebra DataWedge scanners.

Getting Started (under development) #

Example

Initialize the FlutterDataWedge Object and attach a listener to the onScanResult Stream.


    FlutterDataWedge dw = FlutterDataWedge();
    await dw.initialize();
    await createDefaultProfile(profileName: "Example Profile");
    StreamSubscription onScanSubscription = dw.onScanResult.listen((ScanResult result) {
        print(result.data);
    });
    
    [...]
    
    // Stop listening for new scans.
    onScanSubscription.cancel();
    dw.dispose();

dispose() will close all Streams.

Also checkout the example application.

Profiles #

Unlike previous versions, this version of the package won't create a profile and configure it while calling initialize. Instead a profile can be created using the createDefaultProfile method. To query all available profiles use requestProfiles, to query the active profile use requestActiveProfile. The functions waitForProfiles and waitForActiveProfile can be used to wait results after the requesting function has been called.

async/await

Event though the public methods enableScanner(), activateScanner() and scannerControl() are asynchronous they return as soon as the command is executed. Each of these methods (as well as initialize()) will cause ActionResult objects to be emitted on the onScannerEvent Stream. Those can be used to determine the outcome of a command and properly wait for it. Here is a short example:

    FlutterDataWedge dw = FlutterDataWedge();
    await dw.initialize();
    
    // This would be a properly awaited version of enableScanner
    Future<ActionResult> enableScanner() {
        final completer = Completer<ActionResult>();
        final myIdentifier = "someIdentifier";
        
        StreamSubscription onScannerEventSubscription = dw.onScannerEvent.listen((ActionResult result) {
            if (result.commandIdentifier == myIdentifier) {
                completer.complete(result);
            }
        });
        
        
        dw.enablescanner(true,commandIdentifier: myIdentifier);
        
        return completer.future;
    }

Acknowledgements #

The package was started by rafaeljustinox and and contains contributions by LenhartStephan. It is now maintained by Circus Kitchens.

29
likes
0
pub points
91%
popularity

Publisher

verified publishercircuskitchens.com

A Flutter package to communicate with Zebra DataWedge scanners using the DataWedge Intent API

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

async, collection, flutter, freezed_annotation, freezed_result, json_annotation, stream_transform, strict_json, uuid

More

Packages that depend on flutter_datawedge